jose
jose

Reputation: 2543

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,

enter image description here

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

Can anyone help me?

Upvotes: 0

Views: 368

Answers (2)

Martin M&#252;ller
Martin M&#252;ller

Reputation: 2535

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 [email protected] should come from the server ip of abcdefg.com. Else it will be calssified as spam by some mail clients or mail servers.

Upvotes: 1

Borniet
Borniet

Reputation: 3546

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 [email protected] 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

Upvotes: 1

Related Questions