Advertisement
aivavic

mailer

Dec 20th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. // Create the message
  2. $message = Swift_Message::newInstance('My subject');
  3.  
  4. // Set the body
  5. $message->setBody(
  6. '<html>' .
  7. ' <head></head>' .
  8. ' <body>' .
  9. '  Here is an image <img src="' . // Embed the file
  10.      $message->embed(Swift_Image::fromPath('image.png')) .
  11.    '" alt="Image" />' .
  12. '  Rest of message' .
  13. ' </body>' .
  14. '</html>',
  15.   'text/html' // Mark the content-type as HTML
  16. );
  17.  
  18. // You can embed files from a URL if allow_url_fopen is on in php.ini
  19. $message->setBody(
  20. '<html>' .
  21. ' <head></head>' .
  22. ' <body>' .
  23. '  Here is an image <img src="' .
  24.      $message->embed(Swift_Image::fromPath('http://site.tld/logo.png')) .
  25.    '" alt="Image" />' .
  26. '  Rest of message' .
  27. ' </body>' .
  28. '</html>',
  29.   'text/html'
  30. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement