<?php /** * This example shows settings to use when sending via Google's Gmail servers. */ //SMTP needs accurate times, and the PHP time zone MUST be set //This should be done in your php.ini, but this is how to do it if you don't have access to that date_default_timezone_set('Etc/UTC'); require '../PHPMailer/PHPMailerAutoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer; //Tell PHPMailer to use SMTP $mail->isSMTP(); //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 2; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = 'smtp.gmail.com'; // use // $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6 //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->Port = 587; //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; //Whether to use SMTP authentication $mail->SMTPAuth = true; //Username to use for SMTP authentication - use full email address for gmail $mail->Username = "MyUsername@gmail.com"; //Password to use for SMTP authentication $mail->Password = "MyPassword"; //Set who the message is to be sent from $mail->setFrom('MyUsername@yahoo.com', 'Firstname Lastname'); //Set an alternative reply-to address $mail->addReplyTo('MyUsername@yahoo.com', 'Firstname Lastname'); //Set who the message is to be sent to $mail->addAddress('MyUsername@gmail.com', 'Firstname Lastname'); //Set the subject line $mail->Subject = 'PHPMailer GMail SMTP test'; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); //Replace the plain text body with one created manually $mail->AltBody = 'This is a plain-text message body'; //Attach an image file $mail->addAttachment('images/phpmailer_mini.png'); //send the message, check for errors if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?>
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP kb5sm59150446wjc.20 - gsmtp CLIENT -> SERVER: EHLO localhost SERVER -> CLIENT: 250-smtp.gmail.com at your service, [105.112.26.194]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250 SMTPUTF8 CLIENT -> SERVER: STARTTLS SERVER -> CLIENT: 220 2.0.0 Ready to start TLS CLIENT -> SERVER: EHLO localhost SERVER -> CLIENT: 250-smtp.gmail.com at your service, [105.112.26.194]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250 SMTPUTF8 CLIENT -> SERVER: AUTH LOGIN SERVER -> CLIENT: 334 VXNlcm5hbWU6 CLIENT -> SERVER: Y3BsdXNwcm9nQGdtYWlsLmNvbQ== SERVER -> CLIENT: 334 UGFzc3dvcmQ6 CLIENT -> SERVER: Z3JlYXRlcndvcmtzY29uY2VwdHNvcm8= SERVER -> CLIENT: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbudm534-5.7.14 7dRJ9nF9vOvnbQyIqnWIzkoFdffSjNsJB_kyKe-gxiKa06mVdZFiXeMVQDKyojoOrjs8so534-5.7.14 8a0uEyzWF1_Ndjv3Vub5_4IIr6njn6YoBlD32FnjbQO8bu3V6cyoIL7nhiFhktM4_EW3pg534-5.7.14 ErczQyvIUDEbjUUOkYEktvxAbbnCJ9Wd8kJW_3xLYCj9mfHi1T3tjC_bM6OVv-YZfP6CEE534-5.7.14 e_aH7GtdrLmQbnYK5Rpw_MvM7Wes> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 kb5sm59150446wjc.20 - gsmtp SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbudm534-5.7.14 7dRJ9nF9vOvnbQyIqnWIzkoFdffSjNsJB_kyKe-gxiKa06mVdZFiXeMVQDKyojoOrjs8so534-5.7.14 8a0uEyzWF1_Ndjv3Vub5_4IIr6njn6YoBlD32FnjbQO8bu3V6cyoIL7nhiFhktM4_EW3pg534-5.7.14 ErczQyvIUDEbjUUOkYEktvxAbbnCJ9Wd8kJW_3xLYCj9mfHi1T3tjC_bM6OVv-YZfP6CEE534-5.7.14 e_aH7GtdrLmQbnYK5Rpw_MvM7Wes> Please log in via your web browser and534-5.7.14 then try again.534-5.7.14 Learn more at534 5.7.14 https://support.google.com/mail/answer/78754 kb5sm59150446wjc.20 - gsmtp SMTP Error: Could not authenticate. CLIENT -> SERVER: QUIT SERVER -> CLIENT: 221 2.0.0 closing connection kb5sm59150446wjc.20 - gsmtp SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)