Invalid address in PHPMailer

I am getting an error invalid address

while running the PHP script below. The recipient's SMTP credentials and email have been changed for this entry. They are all valid for the actual script. I don't know why the recipient's email is being rejected. I am trying to send an email using SMTP Authentication and SMTP (SSL, TLS) security is not required.

Any help would be appreciated.


  include 'PHPMailer_5.2.2/class.phpmailer.php';

  function SendConfirmation ($sName, $sEmail)
  {
    $mail = new PHPMailer ();

    $mail->SMTPDebug  = 2;

    $mail->Host = "mail.exchange.telus.com";
    $mail->IsSMTP ();
    $mail->Username = "inbin@website.com";
    $mail->Password = "password";

    $mail->From = "inbin@website.com";
    $mail->FromName = "Web Site";

    $mail->AddAddress ($sEmail, $sName);

    $mail->Subject = 'PHPMailer Test' . date ('Y-m-d H:i:s');
    $mail->Body = "This is a test.";

    if ($mail->Send ())
      echo "\r\nMail sent.";
    else
      echo "\r\nMail not sent. " .  $mail->ErrorInfo;

    echo "\r\n";
  }  

  /***[ Main ] **************************************************************************/

  $sName = 'Johan Cyprich';
  $sEmail = 'jcyprich@website.com';

  $bSent = SendConfirmation ($sName, $sEmail);

      

+3


source to share


1 answer


make sure you have valid email addresses for AddReplyTo and / or AddAddress

I had the same problem and it turned out that I was setting empty values ​​for AddReplyTo.



Found information here: http://www.experts-exchange.com/Programming/Misc/Q_28001057.html

+2


source







All Articles