Nitu Dhaka
Nitu Dhaka

Reputation: 1320

change the displayed sender email by phpmailer

Here When I am sending the mail through phpmailer, username testname get on mail. However I want testname to be displayed. What I understand from the phpmailer is the $mail->Username and $mail->Password is required to authentication and $mail->Username is also used at envelope mail. Is there any way to change testname to testname. And I also tried to set $mail->Sender, still not working. I know I am doing some silly mistake here, but I am stuck here now. Any help will be appreciated. Thanks in advance.

    $mail->Username   = '[email protected]';
    $mail->Password   = 'xxxxx';
    $name='testname';

    $mail->SetFrom('testmail.com', $name, true);

    $mail->AddReplyTo('[email protected]','no-reply');
    $mail->Subject    = 'subject';
    $mail->MsgHTML($body);

    $mail->AddAddress('xyz@gmail', 'title1');
    //$mail->AddAddress('[email protected]', 'title2'); /* ... */
    $fileName='../rough/test.pdf';
    $mail->AddAttachment($fileName);

Upvotes: 0

Views: 3602

Answers (2)

mti2935
mti2935

Reputation: 12027

Try adding:

$mail->From = '[email protected]';
$mail->FromName = 'Sender Name';

Also, as Selvin pointed out, gmail is known to rewrite the headers to change the sender info on messages sent through gmail, so that the sender matches the user associated with the gmail account that the message is sent through. See How to change from-address when using gmail smtp server for more info.

Upvotes: 1

Selvin
Selvin

Reputation: 180

If u are send mail from gmail id to another gmail id using PHPmailer gmail assigns the authenticated user id [email protected] as the sender instead of testmail.com and save contact name for [email protected] instead testname

try sending mail to some other provider

Upvotes: 0

Related Questions