是否可以通过PHPmailer为代码添加/更新边界标题
$mail->addStringAttachment($test, 'test.txt', 'quoted-printable');
我需要添加/更新
--b1_KyZbvbrSl55hdWoQf7uUOwdfF2oGjqnCyP6rqNmlA
Content-Type: text/plain; name="test.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=test.txt
看起来像
--b1_KyZbvbrSl55hdWoQf7uUOwdfF2oGjqnCyP6rqNmlA
Content-Type: text/plain; name="test.txt"; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=test.txt
Content-ID: 20cca107-2625-49ce-9357-95254a59147f@127.0.0.1
所以为Content-Type
标题添加了charset
参数,然后添加了新标题Content-ID
有关于此的任何提示吗?
答案 0 :(得分:1)
经过进一步调查后,它出现了
addStringEmbeddedImage方法允许您为其设置cid 附件将为您设置标题。你可以忽略 "图像"在方法名称中 - 它并不关心您的内容类型 真的附上。
所以在我的情况下它将是
$mail->addStringEmbeddedImage(file_get_contents($file_name, FILE_USE_INCLUDE_PATH), $uuid, $file_name, 'base64', '', 'attachment');
关于将charset
参数添加到Content-Type
边界标题
quoted-printable transfer encoding是ASCII 7bit安全的,所以默认 将工作正常,它不需要额外的charset条款。
答案 1 :(得分:0)
对于transfer-encoding和charset
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
'sqlsrv' => [
'sqlsrv_Org' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST'),
'port' => null,//sqlsrv no port
'database' => env('DB_DATABASE2'),
'username' => env('DB_USERNAME2'),
'password' => env('DB_PASSWORD2'),
'charset' => 'utf8',
'prefix' => '',
],
对于content-id,请检查addEmbeddedImage方法或尝试直接添加标题:
$mail->Encoding = 'quoted-printable';
$mail->CharSet = 'UTF-8';