title: PEAR PHP mailing with name from sender
body: <p>I am using PEAR's smtp mailer in PHP and it is working great with attachments CC and BB as well as multiple recipients.  My boss needs the sender to say the name of the sender when it is sent to an email.  Our sales reps say that this is a must.  I tried to follow the directions but when I use the code below the email wont send.  Im guessing that all email types within the mailer have to be written in the same format. For example</p>
  
  <pre><code> //GET EMAIL OF USER
          $result = mysql_query("SELECT email, email_pass, fullname FROM u_perinfo WHERE user_id = '$_SESSION[uid]'")
          or die("There was an error when grabbing your email information");
          if(mysql_num_rows($result) &gt; 0){
              $row = mysql_fetch_array($result);
              if($row[0] != ''){
                  $from = "$row[2] &lt;$row[0]&gt;";
              }
              $email_pass = $row[1];
          }
  
          if(!empty($additional)){
              $email .= ", $additional";
          }
  
          $recipients = array();
          $headers["Subject"] = $subject;
          $headers["From"] = "$from";
          $headers["To"] = "$email";
          $headers["Cc"] = "$cc";
          $headers["Bcc"] = "$bcc";
  </code></pre>
  
  <p>will produce <code>John Doe &lt;johndoe@gmail.com&gt;</code> for the from variable Whereas the the line 
  <code>$from = "$row[2] &lt;$row[0]&gt;;";</code> turned to <code>$from = $row[0]</code> will produce just <code>johndoe@gmail.com</code>
  When doing it with the later (with just the email) it sends the information and works perfectly.  When trying to incorporate the name it doesn't work at all.  Am I doing something wrong?  Any help would be greatly appreciated. </p>
  
  <p><strong>UPDATE</strong>:  this is my mail code that you asked for</p>
  
  <pre><code>$crlf = "\n";
          $mime = new Mail_mime($crlf);
          // Setting the body of the email
          $mime-&gt;setTXTBody($mailmsg);
            $mime-&gt;setHTMLBody($mailmsg);                                           body = $mime-&gt;get();
          $headers = $mime-&gt;headers($headers);
  
          //$mailmsg = "Welcome to Addatareference.com! \r\n\r\nBelow is your unique login information.  \r\n\r\n(Please do not share your login information.)$accountinfo";
          /* SMTP server name, port, user/passwd */
          $smtpinfo["host"] = "smtp.emailsrvr.com";
          $smtpinfo["port"] = "25";
          $smtpinfo["auth"] = true;
          $smtpinfo["username"] = "$from";
          $smtpinfo["password"] = "$email_pass";
          /* Create the mail object using the Mail::factory method */
          $mail_object =&amp; Mail::factory("smtp", $smtpinfo);
          /* Ok send mail */
          $mail_object-&gt;send($recipients, $headers, $body);
  </code></pre>