phalcon-ext / mailer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTML mail with plain text alternative

berliner opened this issue · comments

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.

@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

@KorsaR-ZN Thanks a lot. I wasn't sure that I can modify the result of $message->getSwiftMessage(). It's working, very nice!

Thanks. The issue resolved? :)

Yes!

Can you release 2.0.3 version with this fix, please?