使用SMTP AUTH在PHP中发送邮件

时间:2016-09-13 10:25:50

标签: php email smtp smtpclient smtp-auth

我一直在使用邮件代码在其他服务器上发送邮件而没有任何失败。但是对于特定的新服务器,我需要添加SMTP授权来发送邮件 以下是我在很多R& D之后编写的以下代码。 我仍然无法发送邮件。

$new = "Hi, This is Test mail";
$new .= "</table><table width=\"100%\" align=\"left\" border=\"0\" bordercolor=\"#000000\" cellpadding=\"0\" cellspacing=\"0\" class=Head>                                                                                                  

            <tr><Td colspan=3><strong>This is system generated mail,Please do not respond</strong></Td></tr>
            <tr><Td colspan=3><strong>Thanks</strong>,</Td></tr>
            </table>

    </head>
    </body>
    </html>";

echo $new;  


    $to= "<omg@gmail.com>;\r\n";
$subject = "Test Mail";
$host ='xyz.com';
$username='abc@gmail.com';
$password='89393@998';

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "From:TEST MAIL CRM<abc.gmail.com>\r\n";
    //$headers .= "Bcc:<dd@gmail.com>\r\n";


if(isset($_REQUEST['sendmail'])){
echo $to;
mail($to, $subject, $new, $headers);
    echo "<h1>Mail Send Successfully</h1>";
}

1 个答案:

答案 0 :(得分:-1)