Josemon Maliakal
Josemon Maliakal

Reputation: 65

how to change the content-transfer encoding to 8 bit mime in swiftmailer?

For avoiding the spam message the following was the instruction got from zoho

Until then please change the content-transfer encoding so as to avoid 8 bit mime to prevent DKIM signatures from failing. 

How can change content-transfer encoding with the Swiftmailer or yii2 mailer ?

Upvotes: 0

Views: 1760

Answers (2)

joshpme
joshpme

Reputation: 115

Try using this instead of the plain content encoder

$message->setEncoder(Swift_Encoding::get8BitEncoding());

Upvotes: 0

Bizley
Bizley

Reputation: 18021

If I understand correctly you want to avoid 8-bit encoding and not to set it?

You can set encoder for the SwiftMailer message like:

$message->setEncoder(
    new \Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')
);

I'm not sure how to do this with Yii 2 extension. You can try something like:

$message = Yii::$app->mailer->compose()
    ->setFrom('...')
    ->setTo('...')
    ->setSubject('...');

$message->getSwiftMessage()->setEncoder(
    new \Swift_Mime_ContentEncoder_PlainContentEncoder('7bit')
);

$message->send();

Upvotes: 3

Related Questions