Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Mail

Sender email mismatched with server smtp email

the mail() function

Moderators: macek, egami, gesf

Sender email mismatched with server smtp email

Postby connman » Mon Apr 02, 2012 3:51 am

after doing some SMTP email sending testing, I received email from the sender. However, From: header part, the sender email seems to not match with the sender name. Rather it mismatches with the sender name and SMTP server email instead.

This is the code:-

Code: Select all
<?php



$name = $_POST['username'];

$email = $_POST['email'];

$text = $_POST['inquiry'];



//To, Subject, Message, Header

//mail('conn_man7@hotmail.com', 'Basic Inquiry', $text, 'From: ' . $name . ' <' . $email . '>');



//header('Location: thanks.php');

?>
 
<?php
require_once('class.phpmailer.php');
 
$mail             = new PHPMailer();
 
$body             = $text;
$body             = eregi_replace("[\]",'',$body);
 
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth   = true;                        // enable SMTP authentication
$mail->SMTPSecure = "ssl";                       // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";            // sets GMAIL as the SMTP server
$mail->Port       = 465;                         // set the SMTP port for the GMAIL server
$mail->Username   = "mail@macromac.com.my";     // GMAIL username
$mail->Password   = "q1w2e3r4t5";      // GMAIL password
 
$mail->SetFrom($email, $name);
 
$mail->Subject    = "Product Enquiry";
 
$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
 
$mail->MsgHTML($body);
 
$address = "bill@macromac.com.my";
$mail->AddAddress($address, "Bill");
 
if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
  echo "Message sent!";
}
?>


and this is the output after receiving email as attached...
is there anyway to fix the mismatch issue? Thanks.

screen.png
screen.png (27.55 KiB) Viewed 280 times


test is the sender's name btw.
connman
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Apr 02, 2012 3:39 am

Re: Sender email mismatched with server smtp email

Postby egami » Mon Apr 02, 2012 8:14 am

investigate the headers of the mail.
php.net/mail
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT


Return to PHP coding => Mail

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.