PHP html电子邮件的正确格式

时间:2014-06-24 13:27:57

标签: php html email

$email="jason@home.net";

$message= "CALLERS NAME: ".$values["CallName"]."\r\n";
$message="CALLERS STREET ADDRESS: ".$values["CallStNo"]."\r\n";
$message="STREET DIRECTION: ".$values["CallStDir"]."\r\n";
$message="CALLERS STREET NAME: ".$values["CallStreet"]."\r\n";
$message="ISSUE CALLER IS CALLING ABOUT: ".$values["CallIssue"]."\r\n";
$message="ADDITIONAL INFORMATION: ".$values["CallMisc"]."\r\n"; 
$message="CALLERS PHONE NUMBER: ".$values["CallPhone"]."\r\n";
$message="DATE OF CALL: ".$values["date"]."\r\n";
$message="PERSON WHO TOOK PHONE CALL: ".$values["dataentry"]."\r\n"; 
$message="CURRENT STATUS OF CALL: ".$values["status"]."\r\n";

$subject="Call from Citizen";

 runner_mail(array('to' => $email, 'subject' => $subject, 
  'htmlbody' => $message, 'charset' => 'UTF-8'));

当我构建它时,它只发送一封电子邮件,其中包含消息$ message =" CURRENT STATUS OF CALL:"。$ values [" status"]。 #34; \ r \ n&#34 ;;

和价值。

我是否需要打包邮件,以便在电子邮件中填写所有字段?

1 个答案:

答案 0 :(得分:0)

您已多次设置并重置$message。保留第一个$message(CALLERS名称为1),其他人将其设置为$message .=

您还应避免对变量和回显使用引号,否则可能会重新打开变量调用的回显。将变量调用更改为单引号,如此。

$email="jason@home.net";

$message = "CALLERS NAME: ".$values['CallName']."\r\n";
$message .="CALLERS STREET ADDRESS: ".$values['CallStNo']."\r\n";
$message .= "STREET DIRECTION: ".$values['CallStDir']."\r\n";
$message .= "CALLERS STREET NAME: ".$values['CallStreet']."\r\n";
$message .= "ISSUE CALLER IS CALLING ABOUT: ".$values['CallIssue']."\r\n";
$message .= "ADDITIONAL INFORMATION: ".$values['CallMisc']."\r\n"; 
$message .= "CALLERS PHONE NUMBER: ".$values['CallPhone']."\r\n";
$message .= "DATE OF CALL: ".$values['date']."\r\n";
$message .= "PERSON WHO TOOK PHONE CALL: ".$values['dataentry']."\r\n"; 
$message .= "CURRENT STATUS OF CALL: ".$values['status']."\r\n";

$subject="Call from Citizen";

 runner_mail(array('to' => $email, 'subject' => $subject, 
  'htmlbody' => $message, 'charset' => 'UTF-8'));