简体   繁体   English

尝试使用PHPMAILER发送电子邮件时出错

[英]Error while trying to send email using PHPMAILER

SMTP connect() failed. SMTP connect()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

if(empty($errors)) {
        $mail = new PHPMailer;
        $mail->isSMTP();
        $mail->SMTPAuth = true;
        $mail->Host = 'smtp.gmail.com';
        $mail->Username = 'o.rostom.93@gmail.com';
        $mail->Password = 'XXXXXX'; 
        $mail->SMTPSecure = 'ssl';
        $mail->Port = 465;
        $mail->FromName = $fields['fname'] . ' ' . $fields['lname'];
        $mail->addAddress('o.rostom.93@hotmail.com','Omar Khairy');
        $mail->Body = $fields['message'];
        if(!$mail->Send()) {
           echo $mail->ErrorInfo;
        } else {
            echo "NON";
        }
    }

I have tried manuplating ports, SMTP Secures, nothing is getting better, I have enabled POP and Imap from the gmail, I have also turned on less secure apps, nothing, thanks in advance. 我尝试过操作端口,SMTP安全,一切都没有得到改善,我已经从gmail启用了POP和Imap,我还打开了安全性较低的应用程序,没有,谢谢。

Try using 尝试使用

$mail->SMTPSecure = "tls";              
$mail->Host       = "smtp.gmail.com";
$mail->Port       = 587;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM