title: phpmailer error: invalid address
body: <p>I am trying to build a mail function with php, but it's justing showing "<strong>Invalid address</strong>:" after execute. Pleas help.</p>
  
  <p>Below is my code:</p>
  
  <pre><code>require 'PHPMailerAutoload.php';
  require 'class.phpmailer.php';
  
  $mail = new PHPMailer();  // create a new object
  
  $mail-&gt;IsSMTP(); // enable SMTP
  $mail-&gt;SMTPDebug = 2;  // debugging: 1 = errors and messages, 2 = messages only
  $mail-&gt;SMTPAuth = true;  // authentication enabled
  $mail-&gt;SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
  $mail-&gt;Host = 'smtp.gmail.com';
  $mail-&gt;Port = 465; 
  $mail-&gt;Username = 'myemail@gmail.com';  
  $mail-&gt;Password = 'mypassword';   
  
  $mail-&gt;From = "myemail@gmail.com";
  $mail-&gt;FromName = "Web Site";
  
  $mail-&gt;SetFrom($from, $from_name);
  $mail-&gt;Subject = $subject;
  $mail-&gt;Body = $body;
  $mail-&gt;addAddress('myfriend@gmail.com');
  $mail-&gt;AddReplyTo('myfriend@gmail.com');
  
  if(!$mail-&gt;Send()) {
      $error = 'Mail error: '.$mail-&gt;ErrorInfo; 
      return false;
  } else {
      $error = 'Message sent!';
      return true;
  }
  </code></pre>