Laravel 5.4で動作確認
<?php
namespace App\Mail;
use Illuminate\Mail\Mailable as BaseMailable;
use Swift;
use Swift_DependencyContainer;
use Swift_Preferences;
class Mailable extends BaseMailable
{
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
Swift::init(function () {
Swift_DependencyContainer::getInstance()
->register('mime.qpheaderencoder')
->asAliasOf('mime.base64headerencoder');
});
Swift_Preferences::getInstance()
->setCharset('ISO-2022-JP');
}
/**
* {@inheritdoc}
*/
public function subject($subject)
{
$this->subject = sprintf(
'=?ISO-2022-JP?B?%s?=',
base64_encode(mb_convert_encoding($subject, 'JIS', 'UTF8'))
);
return $this;
}
}