HTML mail with plain text alternative
berliner opened this issue · comments
berliner commented
Hi,
maybe obvious, but I couldn't find information on this neither in the docs nor in the code:
Is it possible to send HTML formatted mails with a plain text alternative?
If so, could you tell me how?
Thanks in advance.
Stanislav Kiryukhin commented
@berliner Hi,
I added a new method in the last commit, please update from master
branch
example
$mailer = new \Phalcon\Ext\Mailer\Manager($config);
$message = $mailer->createMessage()
->to('example_to@gmail.com', 'OPTIONAL NAME')
->subject('Hello world!')
->content('Hello world!');
/**
* Add optionally an alternative body
*
* @param string $content
* @param string $contentType optional
* @param string $charset optional
*
* @return $this
*/
$message->contentAlternative('Your text', $message::CONTENT_TYPE_PLAIN);
P.S
You can also use the method $message->getSwiftMessage()
which returns instance Swift_Message
see docs SwiftMailer
berliner commented
@KorsaR-ZN Thanks a lot. I wasn't sure that I can modify the result of $message->getSwiftMessage()
. It's working, very nice!
Stanislav Kiryukhin commented
Thanks. The issue resolved? :)
berliner commented
Yes!
Wojciech Frącz commented
Can you release 2.0.3 version with this fix, please?
Stanislav Kiryukhin commented