

' embed(Swift_Image::fromPath('image.png')).

>setSubject('Here should be a => 'New Mailtrap => 'Product manager' Public function index($name, \Swift_Mailer $mailer) Here the example of the message with HTML, plain text, attachments, and image: setUsername('1a2b3c4d5e6f7g') For example, if you are going to test emails prior to sending, you should use the Mailer class to send the message with all the credentials of your testing tool. Sending an emailīefore sending, you have to ensure that all the required transport data is set.
#IOS SWIFT SHARE BY EMAIL HOW TO#
How to embed images and attachments into our email is explained in the full tutorial. Put the From Include several To => 'user => 'user Y'įor more details and alternatives, refer to the corresponding section in the Swift Mailer documentation. Also, you can set name headers with associative arrays: // Create the message To include several recipients, use an array and to add recipients in copy, use setCc() or setBcc(). Usually, we will make it with setSubject(), setTo(), and setFrom() methods. In Swift Mailer, messages are composed with the help of Swift_Message class.įrom top to bottom, likely to an email client: set recipient, sender, and a subject. To install Swift Mailer, we need to use Composer: $ composer require "swiftmailer/swiftmailer:^6.0Ĭorrespondingly, to create transport, we need hostname, port, username, and password. Swift Mailer is used as the main mail option in frameworks like Yii2 and CMS like Drupal, Laravael’s email API is built on top of the Swift Mailer library as well. To send messages, you can integrate Swift Mailer into popular sending providers like Sendgrid and similar as well as external SMTP servers.

Swift Mailer is easy to use with any PHP framework. This is an extract from the full tutorial Send Emails with Swift Mailer from PHP Apps
