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
//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) > 0){
$row = mysql_fetch_array($result);
if($row[0] != ''){
$from = "$row[2] <$row[0]>";
}
$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";
will produce John Doe <johndoe@gmail.com>
for the from variable Whereas the the line
$from = "$row[2] <$row[0]>;";
turned to $from = $row[0]
will produce just johndoe@gmail.com
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.
UPDATE: this is my mail code that you asked for
$crlf = "
";
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($mailmsg);
$mime->setHTMLBody($mailmsg); body = $mime->get();
$headers = $mime->headers($headers);
//$mailmsg = "Welcome to Addatareference.com!
Below is your unique login information.
(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 =& Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $body);