dtl4521 2017-07-19 08:47
浏览 17
已采纳

电子邮件发送在PHP上

May mail is working fine but unknown sender error is showing on gmail after sending the mail. My php code is as follows

$sendto="testconcepttc@gmail.com";
$subject = "Payment details of ".$dmail['name'];

$message = "<br><br>";

$message .= '<table border="0" cellspacing="5" cellpadding="4" width="600"style="border-collapse:collapse; font-family:Lucida Sans; border-color:#CCCCCC">

             <tr style="background-color:#023564; color:#FFF;">
          <td colspan="2"><h3 align="center">Registration Information From Midterm Delhi CSI  2017</h3></td>
        </tr>
             <tr>
                  <td width="54%"><p>Name</p></td>
                  <td width="46%"><p>'.$dmail['name'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Age</p></td>
                  <td width="46%"><p>'.$dmail['age'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Institution</p></td>
                  <td width="46%"><p>'.$ucomp.'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Designation</p></td>
                  <td width="46%"><p>'.$dmail['designation'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Postal Address</p></td>
                  <td width="46%"><p>'.$dmail['address'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>City</p></td>
                  <td width="46%"><p>'.$dmail['city'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>State</p></td>
                  <td width="46%"><p>'.$dmail['state'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Pin</p></td>
                  <td width="46%"><p>'.$dmail['pin'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Country</p></td>
                  <td width="46%"><p>'.$dmail['country'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Phone (Off).</p></td>
                  <td width="46%"><p>'.$dmail['phone_off'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Phone (Res).</p></td>
                  <td width="46%"><p>'.$dmail['phone_res'].'</p></td>
                </tr>
                   <tr>
                  <td width="54%"><p>Mobile No</p></td>
                  <td width="46%"><p>'.$dmail['phone'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>E-mail</p></td>
                  <td width="46%"><p>'.$email.'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Gender</p></td>
                  <td width="46%"><p>'.$dmail['gender'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>Food Preference</p></td>
                  <td width="46%"><p>'.$dmail['dite'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>CSI Number</p></td>
                  <td width="46%"><p>'.$dmail['ioa_membership_no'].'</p></td>
                </tr>
                <tr>
                  <td width="54%"><p>MCI Number</p></td>
                  <td width="46%"><p>'.$csi.'</p></td>
                </tr>

                    </table>';


    $username=$dmail['name'];
    $header = "MIME-Version: 1.0
";
    $header .= "Content-type: text/html
";
    $header .= "From: ".$username."
";
    $header .="
";

    $retval = mail ($sendto,$subject,$message,$header);
    return $retval;
  • 写回答

1条回答 默认 最新

  • duanang58939 2017-07-19 08:50
    关注

    Try to add Reply-To header.

    $header .= 'From: from@email.com' . "
    ";
    $header .= 'Reply-To: from@email.com' . "
    ";
    

    OR with name:

    $header .= 'From: "From Name" <from@email.com>' . "
    ";    
    $header .= 'Reply-To: "From Name" <from@email.com>' . "
    ";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line