PHP字符串帮助邮件

时间:2013-08-14 22:58:38

标签: email variables phpmailer php

您需要一些邮件帮助。我正在尝试将此变量的内容插入到字符串中以作为电子邮件发送,还需要添加换行符。还需要将From标题更改为“Procity”和procitystaff@gmail.com

$claim_msg='Hey $claim_username, \n The donator has cancelled your claimed item, but you got your          '    $email_to=$claim_email;
$template=$claim_msg;
$subject= "Claimed item canceled";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1 '.' \r\n';
$headers .= 'From: procitystaff@gmail.com'.' \r\n';
$from='procitystaff@gmail.com';

mail($email_to,$subject,$template,$headers);     

2 个答案:

答案 0 :(得分:1)

你在$email_to之前错过了一个分号,这会导致语法错误。

您在插入php变量时也使用单引号'打印Hey $claim_username而不是双引号",这将打印Hey JohnDoe

答案 1 :(得分:1)

下面代码中第一行末尾缺少分号。另外,我还使用了连接。

试一试。用户名和The donator之间会有换行符。

实施例

嘿约翰,˙ 捐赠者已取消您声明的项目,但您已获得

$claim_msg='Hey ' . $claim_username . ',' . "<br>\n" . 'The donator has cancelled your claimed item, but you got your';
$email_to=$claim_email;
$template=$claim_msg;
$subject= "Claimed item canceled";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1 '.' \r\n';
$headers .= 'From: Procity <procitystaff@gmail.com>' . "\r\n";
$from='procitystaff@gmail.com';

mail($email_to,$subject,$template,$headers);