简体   繁体   中英

change sender e-mail address

I am trying to change the sender's email address to some dynamic value.

I am following this question link here and tried the solution, but still the sender's email is the same as SMTP account username.

Here:

        $mail->Host = "smtp.gmail.com";
        $mail->Port = 465; // or 587
        $mail->Username = "rakesh@gmail.com";
        $mail->Password = 'password';
        $mail->SetFrom($SenderEmail, $SenderName);
        $mail->AddReplyTo($SenderEmail,$SenderName);

But the email header looks like this:

$SenderName <rakesh@gmail.com>

How can I change this?

No, gmail does not allow you to set arbitrary sender addresses. It does allow you to define a limited number of preset aliases in your account settings, but you can't set random addresses at the point of sending. If you do, it will just ignore it and use your account address instead, as you're seeing. This is mentioned in the PHPMailer troubleshooting guide.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM