2010-02-09 11 views
9

Ho provato a utilizzare il mailer php ma gli errori come segue.Errore mailer PHP

SMTP -> FROM SERVER: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: EHLO not accepted from server: 
SMTP -> FROM SERVER: 
SMTP -> ERROR: HELO not accepted from server: 
SMTP -> ERROR: AUTH not accepted from server: 
SMTP -> NOTICE: EOF caught while checking if connectedSMTP Error: Could not authenticate. Message could not be sent. 

Mailer Error: SMTP Error: Could not authenticate. 

e il mio codice

<?php 
     require("class.phpmailer.php") 
     $mail = new PHPMailer();   
     $mail->IsSMTP();          
     $mail->Host = "smtp.gmail.com"; 
     $mail->Port = 465;   
     $mail->SMTPAuth = true;  

     $mail->SMTPDebug = 2; 
     $mail->Username = "[email protected]"; 
     $mail->Password = "xxxxxxxx"; 
     $mail->From = "[email protected]"; 
     $mail->FromName = "Mailer"; 
     $mail->AddAddress("[email protected]", "mine");    
     $mail->WordWrap = 50;         
     $mail->IsHTML(true);         

     $mail->Subject = "Here is the subject" 
     $mail->Body = "This is the HTML message body <b>in bold!</b>"; 
     $mail->AltBody = "This is the body in plain text for non-HTML mail clients"; 


     if(!$mail->Send()) { 
      echo "Message could not be sent. <p>"; 
      echo "Mailer Error: " . $mail->ErrorInfo; 
      exit; 
     } 
     echo "Message has been sent"; 

     ?> 
+0

è necessaria una connessione sicura, non è vero? –

risposta

14

Alcuni server (in particolare di hosting condiviso) si bloccherà di utilizzare SSL con SMTP, ho avuto lo stesso problema una volta.

cambiamento ospite O se è possibile, provare a utilizzare la funzione predefinita di PHP mail() o inviare attraverso un altro server di posta che non richiede SSL per esempio porta 25 non 465.

Qualcosa di simile AuthSMTP sarebbe la soluzione migliore per un server di posta alternativo.

+0

Ho provato a utilizzare la funzione di posta PHp, ma anche quella non veniva inviata. – user2480288

1
non

sicuro, ma cercano $mail->Host = "smtp.gmail.com" =>$mail->Host = "smtp.google.com"

+2

smtp.gmail.com è corretto. – Shoban

+0

oh mi dispiace :) – Young

2

può essere a causa del muro di fuoco?

Se non è possibile accedere a Google Talk, o si sta ricevendo un errore che dice Impossibile autenticarsi al server di , controllare se si dispone di software personal firewall installato, o se il vostro il computer è protetto da un server proxy che richiede un nome utente e una password.

http://www.google.com/support/talk/bin/answer.py?hl=en&answer=30998

+0

talk non è posta, non è vero? – hakre

5

Se state lavorando nel vostro localhost basta andare al PHP Extention e attivare o controllare la php_openssl sarà in grado di accedere alle porte SSL.

8

ho avuto gli stessi problemi, sembra che dobbiamo per impostare il valore SMPTSecure. Per prima cosa ho cambiato il porto 465-587 e ha aggiunto:
$ mail-> smtpsecure = "TLS"; e ha funzionato :)

2

Io uso lo stesso script per diversi client e mi imbatto solo in questo problema durante la distribuzione ai fornitori di cloud Amazon EC2 (come Openshift).

Queste sono le impostazioni testate e collaudate in phpmailer: $ mail-> SMTPSecure = "tls"; // imposta il prefisso al servier $ mail-> Host = "smtp.gmail.com"; // imposta GMAIL come server SMTP $ mail-> Port = 587;

'ma' Google blocca questi servizi come una manovra 'antispam'/politica, e questo mi ha catturato perché funziona localmente e sulla maggior parte dei provider di hosting, non c'è molto che si possa fare quando non lo fanno accetta i messaggi in uscita dai tuoi host DNS/IP. Accettalo e vai avanti cercando un altro server smtp per instradare i messaggi.

3

provare questo codice

require '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'; 

    //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission 
    $mail->Port = 465; 

    //Set the encryption system to use - ssl (deprecated) or tls 
    $mail->SMTPSecure = 'ssl'; 

    //Whether to use SMTP authentication 
    $mail->SMTPAuth = true; 

    //Username to use for SMTP authentication - use full email address for gmail 
    $mail->Username = "[email protected]"; 

    //Password to use for SMTP authentication 
    $mail->Password = "admin123"; 

    $mail->setFrom('[email protected]', 'development'); //add sender email address. 

    $mail->addAddress('[email protected]', "development"); //Set who the message is to be sent to. 
    //Set the subject line 
    $mail->Subject = $response->subject; 

    //Read an HTML message body from an external file, convert referenced images to embedded, 
    //convert HTML into a basic plain-text alternative body 
    $mail->Body  = 'Name: '.$data['name'].'<br />Location: '.$data['location'].'<br />Email: '.$data['email'].'<br />Phone:'.$data['phone'].'<br />ailment: '.$data['ailment'].'<br />symptoms: '.$data['symptoms']; 

    //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.gif'); 
    //$mail->SMTPAuth = true; 
    //send the message, check for errors 
    if (!$mail->send()) { 
     echo "Mailer Error: " . $mail->ErrorInfo; 
    } else { 
     echo "Message sent!"; 
    } 
+0

$ mail-> SMTPSecure = 'ssl'; ha fatto la differenza per me, grazie! –

+0

@ Cyrille Armanger accetta la risposta se è un lavoro :) grazie in anticipo – Priyank

+0

Non sono il poster originale, mi ha semplicemente aiutato. –

2

avevano lo stesso problema, modificare porto No in ambiente di posta OpenCart a 587 e funziona bene

+0

Questo ha funzionato per me. – herrmartell