纯文本电子邮件中的换行符

时间:2015-11-05 03:22:06

标签: php plaintext

这一定很简单,因为我的PHP技能最多也很弱......

我有以下行生成我为工作申请发送的电子邮件,电子邮件正确到达但没有换行符,它似乎打印\ n(尝试过\ r \ n)

$contact->setBodyMessageFields('Job Ref: [jobref] \n Vacancy Desc: [vacdesc] \n Full Name: [firstname] [lastname] \n Address: [address] \n Suburb: [suburb] \n Post Code: [postcode] \n Email: [mail] \n Phone: [phone] \n Mobile: [mobile] \n Message: [message] \n ');

所以很明显,\''('')字面打印所有内容,我试过:

$contact->setBodyMessageFields('Job Ref: [jobref] '\n' Vacancy Desc:

但这似乎会引发错误。

非常感谢任何帮助。

请注意:遗憾的是,由于另一个系统提取数据(并且需要纯文本),因此必须是纯文本。

1 个答案:

答案 0 :(得分:0)

您应该用双引号替换单引号:

$contact->setBodyMessageFields("Job Ref: [jobref] \n Vacancy Desc: [vacdesc] \n Full Name: [firstname] [lastname] \n Address: [address] \n Suburb: [suburb] \n Post Code: [postcode] \n Email: [mail] \n Phone: [phone] \n Mobile: [mobile] \n Message: [message] \n ");

有关详细信息,请参阅strings上的PHP.net文章。