php-swiftmailerHow to embed an image in Swiftmailer?
To embed an image in Swiftmailer, you need to use the Embed()
method. This method takes the image file path as an argument and returns a Swift_Image
object.
Example code
$image = $message->embed(Swift_Image::fromPath('path/to/image.jpg'));
Output example
Swift_Image Object
(
[_name:protected] => Swift_Image
[_file:protected] => path/to/image.jpg
)
Code explanation
$message
: an instance ofSwift_Message
classEmbed()
: a method ofSwift_Message
classSwift_Image
: a classfromPath()
: a static method ofSwift_Image
class$image
: a variable to store theSwift_Image
object
Helpful links
More of Php Swiftmailer
- How to use SMTP with Swiftmailer?
- How to set timeout with Swiftmailer?
- How to use TLS 1.2 with Swiftmailer?
- How to configure Swiftmailer for SMTP without authentication?
- How to send emails in UTF8 using Swiftmailer?
- How to get the error message in Swiftmailer?
- How to use Swiftmailer transport?
- How to use Swiftmailer with Symfony?
- How to use Swiftmailer to send RFC 2822 compliant emails?
- How to send emails with Swiftmailer?
See more codes...