Unable to send email using Gmail SMTP server through PHPMailer, getting error: SMTP AUTH is required for message submission on port 587. How to fix?

前端 未结 12 2420
[愿得一人]
[愿得一人] 2020-11-22 02:42

I would like to send an email using Gmail SMTP server through PHP Mailer.

this is my code



        
12条回答
  •  一个人的身影
    2020-11-22 03:14

    I think it is connection issue you can get code here http://skillrow.com/sending-mail-using-smtp-and-php/

    include(“smtpfile.php“);
    include(“saslfile.php“); // for SASL authentication $from=”my@website.com“; //from mail id
    
    $smtp=new smtp_class;
    
    $smtp->host_name=”www.abc.com“; // name of host
    $smtp->host_port=25;//port of host
    
    $smtp->timeout=10;
    $smtp->data_timeout=0;
    $smtp->debug=1;
    $smtp->html_debug=1;
    $smtp->pop3_auth_host=””;
    $smtp->ssl=0;
    $smtp->start_tls=0;
    $smtp->localhost=”localhost“;
    $smtp->direct_delivery=0;
    
    $smtp->user=”smtp username”;
    $smtp->realm=””;
    $smtp->password=”smtp password“;
    
    $smtp->workstation=””;
    $smtp->authentication_mechanism=””;
    
    $mail=$smtp->SendMessage($from,array($to),array(“From:$from”,”To: $to”,”Subject: $subject”,”Date: ”.strftime(“%a, %d %b %Y %H:%M:%S %Z”)),”$message”);
    
    if($mail){
       echo “Mail sent“;
    }else{
       echo $smtp->error;
    }
    

提交回复
热议问题