iT邦幫忙

0

PHP email function

$account="xxx@gmail.com";
$password="";
$to="xxx@hotmail.com";
$from="xxx@gmail.com";
$from_name="Vishal G.V";
$msg="This is a bold text."; // HTML message
$subject="HTML message";
/End Config/

include("phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->CharSet = 'UTF-8';
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth= true;
$mail->Port = 587; // Or 465
$mail->Username= $account;
$mail->Password= $password;
$mail->SMTPSecure = 'tls'; // or 'ssl'
$mail->From = $from;
$mail->FromName= $from_name;
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->addAddress($to);
if(!$mail->send()){
echo "Mailer Error: " . $mail->ErrorInfo;
}else{
echo "E-Mail has been sent";
}

Mailer Error: SMTP Error: Could not authenticate.

有沒人遇到類似情況?

mkmkmk iT邦新手 3 級 ‧ 2017-11-21 14:45:31 檢舉
ssl + 465. 本人一路使用中.
請留意, 要去你的google account開啓"[允許安全性較低的應用程式] 設定處於啟用狀態". 這樣才能使用.
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

WilliamHuang
iT邦研究生 1 級 ‧ 2017-11-15 15:03:40
【**此則訊息已被站方移除**】
0
黃彥儒
iT邦高手 1 級 ‧ 2017-11-15 15:48:27

samit,有成功連線出去了,只是伺服器驗證沒過,本機的工作已經完成囉~
Gmail的話要看看是不是有強驗證,若是有的話要建立應用程式密碼

看更多先前的回應...收起先前的回應...
samit iT邦新手 5 級 ‧ 2017-11-15 15:55:51 檢舉

只是伺服器驗證沒過 即係伺服器管理員處理, 對?
我看過Gmail 有強驗証, 如何建立?

黃彥儒 iT邦高手 1 級 ‧ 2017-11-15 15:58:17 檢舉

1:https://ithelp.ithome.com.tw/upload/images/20171115/20088395dRQwAmTCsS.jpg
2:https://ithelp.ithome.com.tw/upload/images/20171115/20088395A6u9oukdIp.jpg
3:https://ithelp.ithome.com.tw/upload/images/20171115/200883959ZgS3OgD2i.jpg

samit iT邦新手 5 級 ‧ 2017-11-15 16:01:36 檢舉

解決了,
我是跟進https://digishot.keenchief.com/tw/2928511342 就成功了

WilliamHuang iT邦研究生 1 級 ‧ 2017-11-15 16:05:30
【**此則訊息已被站方移除**】
samit iT邦新手 5 級 ‧ 2017-11-15 16:07:39 檢舉

哈.. 謝謝你指正

何必問 iT邦好手 1 級 ‧ 2017-11-16 21:46:15 檢舉

看來您的phpmailer還是用舊寫法
請留意phpmailer舊版漏洞
Ref. https://www.nccst.nat.gov.tw/VulnerabilityDetail?lang=zh&seq=1048

新的已改成引用

require_once( dirname(FILE)."/lib/PHPMailerAutoload.php" );

samit iT邦新手 5 級 ‧ 2018-02-01 11:30:56 檢舉

wow..感謝萬分

我要發表回答

立即登入回答