简体   繁体   中英

PHP mail from address header

I'm using PHP mail function to send messages from my web app. I've created a table which holds the e-mail addresses and messages to send. The script fetches a certain number of messages and sends them.

$headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=' . $charset . "\r\n";
            $headers .= 'To: ' . $destName . ' <' . $destAddress . '>' . "\r\n";
            $headers .= 'From:' . $fromName . ' <' . $fromAddress . '>' . "\r\n";
            $headers .= "Reply-To: ". $fromName . ' <' . $fromAddress . '>' . "\r\n";

            mail($destAddress, $subject, $msgBody, $headers);

My problem is that, even setting the FROM and REPLY-TO header, the address shown on the list of received messages is strange (not the one I've sent). See picture below,

在此输入图像描述

But when I open the message, it seems all is OK, ie the sender is the one I've configured.

Can anyone help me?

If there would be nothing that shows that the "from" and "reply-to" field are different from the address from where the mail was sent, then everyone would be able to sent you a mail coming from for instance obama@whitehouse.org If you want the email of your choice to be shown, you should use smtp, log in to the mailserver with the correct account, and sent the mail. This will cause the mail to be verified and trusted. http://www.9lessons.info/2009/10/send-mail-using-smtp-and-php.html

This is probably an issue with the web interface of dispostable.com which does not show the contents of the "from" but the address of the sending mailserver in the overview. This might be a security measure. Dis you try to send to a "normal" address?

By the way, the address in "from" should be resolvable to the server from where it was sent. For example a mail from admin@abcdefg.com should come from the server ip of abcdefg.com. Else it will be calssified as spam by some mail clients or mail servers.

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