php - Server responding very slow to PHPMailer gmail SMTP -


i using example code provided in phpmailer. firstly, code executes slow (atleast 1-2 minutes of loading in browser) , gives me errors.

<?php /** * example shows settings use when sending via google's gmail servers. */  //smtp needs accurate times, , php time zone must set //this should done in php.ini, how if don't have access date_default_timezone_set('etc/utc');  require 'phpmailer/phpmailerautoload.php';  //create new phpmailer instance $mail = new phpmailer;  //tell phpmailer use smtp $mail->issmtp();  //enable smtp debugging // 0 = off (for production use) // 1 = client messages  // 2 = client , server messages $mail->smtpdebug = 2;  //ask html-friendly debug output $mail->debugoutput = 'html';  //set hostname of mail server $mail->host = 'smtp.gmail.com';  //set smtp port number - 587 authenticated tls, a.k.a. rfc4409 smtp submission $mail->port = 587;  //set encryption system use - ssl (deprecated) or tls $mail->smtpsecure = 'tls';  //whether use smtp authentication $mail->smtpauth = true;  //username use smtp authentication - use full email address gmail $mail->username = "mygmailid@gmail.com";  //password use smtp authentication $mail->password = "mypassword";  //set message sent $mail->setfrom('mygmailid@gmail.com', 'andrew mathew');  //set alternative reply-to address $mail->addreplyto('mygmailid@gmail.com', 'andrew mathew');  //set message sent $mail->addaddress('myotherid@gmail.com', 'john doe');  //set subject line $mail->subject = 'phpmailer gmail smtp test';  //read html message body external file, convert referenced images embedded, //convert html basic plain-text alternative body $mail->msghtml(file_get_contents('contents.html'), dirname(__file__));  //replace plain text body 1 created manually $mail->altbody = 'this plain-text message body';  //attach image file //$mail->addattachment('images/phpmailer_mini.png');  //send message, check errors if (!$mail->send()) { echo "mailer error: " . $mail->errorinfo; } else { echo "message sent!";  } ?> 

errors receive is-

smtp error: failed connect server: (0) smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting mailer error: smtp connect() failed. https://github.com/phpmailer/phpmailer/wiki/troubleshooting

i have authorized gmail account use google's less secure app. there other changes need make in server or in php configuration files make work?

p.s. have not installed on server, have downloaded phpmailer github , placed in working directory.

this not phpmailer bug, it's problem server. if read troubleshooting docs linked in error message (why it's there) give suggestions try figure out wrong connectivity. it's either dns lookups failing or network not letting out.

setting smtpdebug=3 provide lower level debug output relating connection.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -