email - php PHPMailer shared hosting override default dns server -


i having dns problems running phpmailer accessing smtp.office365.com on new cpanel shared hosting plan register365.com.

my code has worked years on older shared hosting plan same provider. , works fine on test windows iis system , shared hosting plan provider. problem unique register365.com

i getting connection error after 300 secs: connection failed. error #2: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: temporary failure in name resolution

the standard troubleshooter info in phpmailer led me to suspect dns. contacted provider register365.com , told me:

thank getting in touch dns.

firstly our nameservers non recursive return results domains hosted on them if try , query smtp.office365.com on our nameservers not going work not hosted us. if phpmail script querying our servers find address wont work , bring error seeing.

you need set php script query general dns such googles , resolve issue.

unfortunately there nothing can in situation resolve issue.

first, response make sense? if does, how can proceed? so, able either force phpmailer use say, google's 8.8.8.8 dns server when tries resolve smtp.office365.com initial connection or somehow force php change default dns servers. don't want hard-code ip address $mail->host field microsoft change them on time.

i looking advice on how proceed. (you may "use different hosting provider" various financial can't!)

<!doctype html> <html> <html lang="en"> <meta charset="utf-8" /> <title>test office365 in  microsoft register365.com</title> <link rel="stylesheet" href="/styles/trekkersfluid.css" type ="text/css" /> </head>  <body class="blank"> <?php     error_reporting(e_all);     ini_set('display_errors', 1);     require('../phpmailer/phpmailerautoload.php');     $mail = new phpmailer;     $mail->le = "\r\n";     $mail->charset = 'utf-8';     $mail->smtpdebug = 4;                                        $mail->debugoutput = 'html';     $mail->issmtp();     $mail->host = "smtp.office365.com";                         // specify main office 365 smtp server     $mail->smtpauth = true;                                 // enable smtp authentication     $mail->username = 'trekkersend@trekkers.ie';            // smtp username     $mail->password = 'mypassword';                          // smtp password      $mail->smtpsecure = 'tls';                              // enable tls encryption, `ssl` accepted     $mail->port = 587;                                      // tcp port connect to. tls = 587 ssl = 465       //set address     $fromname = "joe murray";     $mail->setfrom("trekkersend@trekkers.ie");       $mail->addreplyto("rubbish@jma.ie", "rubbish name");     $mail->addaddress("joseph@jma.ie", "joseph murray");      $mail->wordwrap = 70;                                 // set word wrap 70 characters      $mail->ishtml(true);                                  // set email format html      $mail->subject = "testing microsoft exchange online service";     $mail->body    = "this test";      if(!$mail->send()) {         echo '<p class="error_msg">message not sent.</p>';         echo '<p class="error_msg">mailer error: ' . $mail->errorinfo."</p>";         exit();     } else {         echo '<p class="green">'."email sent</p>";      }      ?> 

to validate provider's statement, try resolving names other smtp.office365.com, e.g. google.com. know sure whether provider's dns server non-recursive. must say, though, sounds strange me physical or virtual machine on webhost running not configured use dns server useful.


as workaround, suggest using google's public dns-over-http api query dns servers (8.8.8.8 , 8.8.4.4):

https://dns.google.com/resolve?name=smtp.office365.com

but ironically, facing same problem here, can't resolve dns.google.com.


the other solution can see @ moment directly query public dns server (like 8.8.8.8) via tcp or udp.

if hoster provides access shell, can use tool nslookup (see this su question details).

if don't have access shell, this question might prove helpful in order resolve names php.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -