Jump to content

phpmailer from header


Tikkie

Recommended Posts

I'm new to PHP and working on a mailform with phpmailer with attachment. Everything works fine but the received mail keeps having my Gmail address in the from header.

The AddReplyTo address works fine but I don't want to show the gmail address.

 

This is what my code looks like:

 

 


require('C:\xampp\htdocs\PHPMailer\class.phpmailer.php');
 
$mail = new PHPMailer();  // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 2;  // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;  // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; 
$mail->Username = '[email protected]';  
$mail->Password = 'mypassword'; 
$mail->AddReplyTo('[email protected]', '[email protected]');
 
$mail->AddAddress("[email protected]", "MyAccount");
$mail->Subject = "TestMail";
$mail->Body    = "This is the message body";
$mail->AddAttachment("test.txt", "test.txt");  // optional name
if(!$mail->Send())
{
   echo "Error";
   exit;
}
else {
echo "OK";
}

 

 

 

I only want to use the gmail smtp but want to show another e-mail address ([email protected] in thie example) in the header. But it keeps showing [email protected].

Also in the class.phpmailer.php I've configurated the $From, $FromName and $Sender as [email protected] but this doesn't work.

 

Can somebody help me with this?

Link to comment
https://forums.phpfreaks.com/topic/285258-phpmailer-from-header/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.