您需要一些邮件帮助。我正在尝试将此变量的内容插入到字符串中以作为电子邮件发送,还需要添加换行符。还需要将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);
答案 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);