php - phpMailer not working after being hosted -
this question has reply here:
how specify smtp server in phpmailer? 1 replyphpmailer script works fine on localhost 1 time uploaded on 000webhost.com gives me error message:
smtp -> error: failed connect server: connection timed out (110) next address failed: abc@gmail.com : called mail() without beingness connected mailer error: next address failed: abc@gmail.com : called mail() without beingness connected here script:
<?php require_once('class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called within class.phpmailer.php if not loaded ////////extracting form info post///////// $course = $_request["course__2"]; $receiver_name = $_request["name__1"]; $receiver_email = $_request["email__3"]; ///////////////// $mail = new phpmailer(); $body = "hi ."; $mail->issmtp(); // telling class utilize smtp $mail->host = "smtp.gmail.com"; // sets gmail smtp server $mail->port = 587; // set smtp port gmail server $mail->smtpauth = true; // enable smtp authentication $mail->username = "abc@gmail.com"; // gmail username $mail->password = "00000000"; // gmail password $mail->smtpsecure = "tls"; // sets prefix servier $mail->smtpdebug = 1; // enables smtp debug info (for testing) // 1 = errors , messages // 2 = messages $mail->setfrom('abc@gmail.com', ' global'); //sender's email address $mail->addreplyto("abc@gmail.com","global"); //a reply address $mail->subject = "10% off voucher"; $mail->altbody = "to view message, please utilize html compatible email viewer!"; // optional, comment out , test $mail->msghtml($body); $address = $receiver_email; //receiver's address $mail->addaddress($address, $receiver_name); //name of receiver if(!$mail->send()) { echo "mailer error: " . $mail->errorinfo; } else { echo "message sent!"; } ?> is problem hosting provider or wrong code?
it host not have openssl extensions activated apache php reason.
that said, don’t need smtp send mails. in fact typical way 1 sends mails on unix/linux host via local sendmail smtp. since using phpmailer looking in examples/ folder in phpmailer repository shows there sendmail example. wold recommend utilize instead of smtp on remote host:
require '../phpmailerautoload.php'; //create new phpmailer instance $mail = new phpmailer(); // set phpmailer utilize sendmail transport $mail->issendmail(); //set message sent $mail->setfrom('from@example.com', 'first last'); //set alternative reply-to address $mail->addreplyto('replyto@example.com', 'first last'); //set message sent $mail->addaddress('whoto@example.com', 'john doe'); //set subject line $mail->subject = 'phpmailer sendmail 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!"; } also, way check if remote server @ 000webhost allowing access google’s tls port utilize script found in answer. take , place in php file on host & load in web browser.
<?php $fp = fsockopen('tls://smtp.gmail.com:465'); if(!$fp) { echo 'unable connect'; } else { $response = fgets($fp, 256); echo 'response: ' . $response; } ?> the success message getting is:
response: 220 mx.google.com esmtp r14sm2233165qga.4 - gsmtp
if fails response this:
warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known in /applications/mamp/htdocs/test.php on line 3
and if fails, know there issues 000webhost , output tls connections gmail.
php timeout phpmailer
No comments:
Post a Comment