发送电子邮件错误


Error in sending email

我正在使用php脚本发送电子邮件。我想显示用户名在从和他的电子邮件id在回复路径。我使用下面的代码。我在message.

中使用html。
 Error.: It is not showing the from in email , showing unknow sender.

  <?php  
 $name="TEST TEST";
 $from1=test@gmail.com
 $msg='<div>hello dfjdk faofd akfda </div>';
 $to =$email;
 $subject = $ab." Return SMS";
  $message = $msg;
  $from1 = 'test@yahoo.com';
  $headers = "From:$name'r'n";
  $headers .= "MIME-Version: 1.0'n";
  $headers .= 'Content-Type: text/html; charset="iso-8859-1"'."'n";
 $headers .= "Reply-To: $from1'r'n";
   mail($to,$subject,$message,$headers);
  ?>

试试这个:

<?php  
  $to = $email;
  $subject = $ab." Return SMS";
  $message = '<div>hello dfjdk faofd akfda </div>';
  $name = "TEST TEST";
  $from1 = "test@gmail.com";
  $headers = "From: $name <$from1>'r'n";
  $headers .= "MIME-Version: 1.0'n";
  $headers .= 'Content-Type: text/html; charset="iso-8859-1"'."'n";
  $headers .= "Reply-To: $name <$from1>'r'n";
  mail($to, $subject, $message, $headers);
?>

首先,你的标记是完全错误的。

$from=test@gmail.com

这是无效的php。$from = "test@gmail.com"

接下来,在第一个标题行中,From:$name也是一个问题。$name应为发件人的电子邮件。