Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php上发送电子邮件_Php_Email_Gmail - Fatal编程技术网

在php上发送电子邮件

在php上发送电子邮件,php,email,gmail,Php,Email,Gmail,May mail运行正常,但发送邮件后gmail上显示未知发件人错误。我的php代码如下 $sendto="testconcepttc@gmail.com"; $subject = "Payment details of ".$dmail['name']; $message = "<br><br>"; $message .= '<table border="0" cellspacing="5" cellpadding="4" width="600"style="

May mail运行正常,但发送邮件后gmail上显示未知发件人错误。我的php代码如下

$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\r\n";
    $header .= "Content-type: text/html\r\n";
    $header .= "From: ".$username."\r\n";
    $header .="\r\n";

    $retval = mail ($sendto,$subject,$message,$header);
    return $retval;

尝试将回复添加到标题

$header .= 'From: from@email.com' . "\r\n";
$header .= 'Reply-To: from@email.com' . "\r\n";
或姓名:

$header .= 'From: "From Name" <from@email.com>' . "\r\n";    
$header .= 'Reply-To: "From Name" <from@email.com>' . "\r\n";

电子邮件的发件人是发送邮件的人,而不是邮件发送到的地址…$username中的内容我猜它不是电子邮件地址Don't give From as$username。给noreply@example.comI建议同时使用From和Reply-to。是的!但是因为From:地址看起来像是错误的原因,所以最好先解决这个问题,我已经更改了我的答案。