使用SwiftMailer发送原始电子邮件标头

时间:2016-08-02 06:49:47

标签: php email swiftmailer email-headers

我想要的是使用SwiftMailer发送原始标头

目前这是我可以用SwiftMailer做的事情

// Create the message
$message = Swift_Message::newInstance();
$message->setSubject("This email is sent using Swift Mailer");
$message->setBody("You {fullname}, are our best client ever thanks " .
    " to the {transactions} transactions you made with us.");
$message->setFrom("account@bank.com", "Your bank");

使用$message->setFrom()我可以在标题中设置From字段,但我想要的是这样的

$rawHeader = 'MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="_=_swift_v4_1467746603_bb0677c43b2ba275b8602c907ef7228a_=_"
List-Unsubscribe: <http://go.proctorgallagher.com/unsubscribe/u/45802/41c5731bb75f7959e5880279725cb9b7b4f8996214976c36a0f93e36e88e7705/876424750>
X-Report-Abuse-To: abuse@pd25.com
x-job: 7215816_12853

--_=_swift_v4_1467746603_bb0677c43b2ba275b8602c907ef7228a_=_
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable'

$message->rawHeader($rawHeader);

或者我不必让swiftmailer知道Content-Type字段和值是text/plain

我的意思是我发送的任何内容,因为它不必单独放置所有内容。

1 个答案:

答案 0 :(得分:0)

你试过了吗?

$message->setBody("You {fullname}, are our best client ever thanks " .
    " to the {transactions} transactions you made with us.", "text/plain", "utf-8");