문제

I would like to send an auto-generated email with HTML body from my application using Swift.

Here is my current code:

$message = Swift_Message::newInstance()
                ->setFrom(array('dummy1@test.com' => 'John Doe'))
                ->setTo('dymmy2@test.com')
                ->setSubject('some subject');

            $message->setBody($this->getPartial('global/mail_partial'));

            $this->getMailer()->send($message);

I had already tried to change the header Content-type of the email message using some specific Swift methods but it is not working.

도움이 되었습니까?

해결책

See:

Sending a HTML E-Mail (from SwiftMailer Docs)

You need to add this line to set html content-type:

$message->setContentType("text/html");

Alternatively, it can by done passing a second argument on the $message->setBody() method:

$message->setBody($this->getPartial('global/mail_partial'), 'text/html');.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top