如何使用PHPMailer向gmail帐户发送电子邮件? [英] How to send email to gmail account using PHPMailer?
本文介绍了如何使用PHPMailer向gmail帐户发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我尝试使用PHPMailer发送电子邮件,这里是我的代码:
Hi there, I try to send email using PHPMailer, here my code:
require '/****/*****/******/PHPMailer-master/PHPMailerAutoload.php';
$mailltoadm = new PHPMailer;
$mailltoadm->isSMTP(); // Set mailer to use SMTP
$mailltoadm->Host = 'localhost'; // Specify main and backup SMTP servers
$mailltoadm->SMTPAuth = true; // Enable SMTP authentication
$mailltoadm->Username = '******@*******.com'; // SMTP username
$mailltoadm->Password = '*******'; // SMTP password
$mailltoadm->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mailltoadm->From = $emaillogin; //EMAIL PENGIRIM
$mailltoadm->FromName = $userloginname; //NAMA PENGIRIM
$mailltoadm->addAddress($mastermaill, $name_store); // Add a recipient (PENERIMA)
$mailltoadm->addAddress($mastermaill);
$mailltoadm->addReplyTo($emaillogin, $userloginname);
$mailltoadm->WordWrap = 50; // Set word wrap to 50 characters
$mailltoadm->isHTML(true); // Set email format to HTML
$mailltoadm->Subject = 'New Order '. $name_store;
$mailltoadm->Body = $finishorder; //HTML SUPPORT
$mailltoadm->AltBody = convert_html_to_text($finishorder); //NON HTML
if(!$mailltoadm->send())
{
echo 'Mailer to admin Error: ' . $mailltoadm->ErrorInfo."<br/>";
}
else
{
echo 'Message to admin has been sent'."<br/>";
}
为什么电子邮件发送到***@yahoo.com成功,但不发送到*** @ gmail .com?
可以帮助我。
why email send to ***@yahoo.com success, but not send to ***@gmail.com ?
can any one help me please.
推荐答案
mailltoadm = new PHPMailer;
mailltoadm = new PHPMailer;
mailltoadm-> isSMTP(); // 将邮件程序设置为使用SMTP
mailltoadm->isSMTP(); // Set mailer to use SMTP
mailltoadm-> Host = ' localhost'; // 指定主要和备用SMTP服务器
mailltoadm->Host = 'localhost'; // Specify main and backup SMTP servers
这篇关于如何使用PHPMailer向gmail帐户发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文