php - PHPMailer smtp connect() failed on ovh server -
i'm using phpmailer send daily emailing (max 100 emails), script works fine on local, when uploaded server (hosted on ovh) blocks , generate error after sending average of 20 emails
smtp connect() failed https://github.com/phpmailer/phpmailer/wiki/troubleshooting
i contacted ovh , sad there no problems email adresse think bug on code, here code:
$m = new phpmailer; $mail = new mailing(); $admin = new administrateur(); $m->issmtp(); $m->ishtml(true); $m->smtpauth = true; $m->smtpdebug = 0; $m->smtpkeepalive = true; $m->host = 'ssl0.ovh.net'; $m->username = 'exemple@exemple.com'; $m->password = 'xxxxxxxxxxx'; $m->smtpsecure = 'ssl'; $m->port = "465"; $m->charset = 'utf-8'; $m->from = 'exemple@exemple.com'; $m->fromname = 'chantier tn'; $m->addreplyto('exemple@exemple.com', 'reply adress'); $m->subject = 'alerte quotidienne'; $error = false; $alertes = session::get('alertes'); $date = date('y-m-d h:i:s'); $token = $alertes[$id]['id_cli'].'-'.strtotime($date); $m->addaddress($alertes[$id]['email'], strtoupper($alertes[$id]['nom']).' '.$alertes[$id]['prenom']); session::delete('send'); $m->body = $mail->generatebodyforalerte(strtoupper($alertes[$id]['nom']).' '.$alertes[$id]['prenom'], $alertes[$id]['leads'], $token); if ($m->send()) { $mail->set('type_mail', 1); $mail->set('date_send', $date); $mail->set('id_cli', $alertes[$id]['id_cli']); $mail->set('id_op', $admin->getid()); $mail->set('content', session::get('send')); $mail->save(); $s = session::exists('sent') ? session::get('sent') : array(); $s[] = $alertes[$id]['email']; session::put('sent', $s); } else{ $error = $m->errorinfo; $s = session::exists('notsend') ? session::get('notsend') : array(); $s[] = $alertes[$id]['email'].' error: '.$error; session::put('notsend', $s); } $m->clearaddresses(); if (!isset($_session['alertes'][$id+1])) { $next = false; } else{ $next = $id+1; }
the list of emails stored in session loop on id, id url using mvc structure, after executing code, render view wich display list of sent email, , if there error echo out email adresse error, after 5 seconds redirect same page next id using jquery. here picture of output:
as docs point out:
"smtp error: not connect smtp host."
this may appear smtp connect() failed or called mail() without being connected in debug output. reported phpmailer problem, it's down local dns failure, firewall blocking or other issue on local network. means phpmailer unable contact smtp server have specified in host property, doesn't why. can caused not having openssl extension loaded (see encryption notes below).
so advice set:
$m->smtpdebug = 4;
to more detailed message , change 0
once figure out cause.
post extended debug info here, can further it.
debug info (from comment - removed timestamp):
server -> client: 250-ns0.ovh.net connect mail751 250-auth login plain 250-auth=login plain 250-8bitmime 250 size 109000000
auth method requested: unknown
auth methods available on server: login,plain
auth method selected: login
client -> server: auth login
smtp -> get_lines(): $data ""
smtp -> get_lines(): $str "334 vxnlcm5hbwu6 "
server -> client: 334 vxnlcm5hbwu6
client -> server: bm9yzxbseubjagfudgllci50bg==
smtp -> get_lines(): $data ""
smtp -> get_lines(): $str "334 ugfzc3dvcmq6 "
server -> client: 334 ugfzc3dvcmq6
client -> server: y2lumjm0njq4odq=
smtp -> get_lines(): $data ""
smtp -> get_lines(): $str "535 authorization failed (#5.7.0) "
server -> client: 535 authorization failed (#5.7.0)
smtp error: password command failed: 535 authorization failed (#5.7.0)
smtp error: not authenticate.
client -> server: quit
smtp -> get_lines(): $data ""
smtp -> get_lines(): $str "221 ns0.ovh.net connect mail751 "
server -> client: 221 ns0.ovh.net connect mail751
connection: closed
so, apparently, ovh not authenticating you. perhaps ovh somehow rate-limiting you?
Comments
Post a Comment