简体   繁体   中英

Sending a text message with the PHP mail Function (Parameter 'From' does not work)

I am working with the mail function in PHP.

It has an optional parameter "From" where you can input an address and the recipient of the email will see that the mail was sent from that email address.

This PHP function works fine when sending to my AOL email account, but when I tried to send it to my cell phone number (cell number)@vtext.com, the message is delivered, but the sender's address shows up as (myusername)@box489.bluehost.com, instead of the "From" parameter(myaddress@mydomain.com).

However, when I send a message to my phone through the online webmail app manually the sender address shows up correct(myaddress@mydomain.com).

Can anyone help me out with this?

It needs to come from a real address. Telcos use a service like senderbase.com from cisco, when they receive the message they are going to check reputation, spf records, rdns and possibly more. I created a sms system some time ago and i ended up using the PEAR mail package to authenticate with an email address on my mail server through smtp then send the message... also even tho you may be sending the message from a real email, the mail() function will send from the IP of the webserver not mail server, which they will also check against.

such an annoying problem, isn't it? here's a solution i came across finally :)

--

$headers = 'From: noreply@domain.com';

mail($to, $subject, $message, $headers, '-fnoreply@domain.com');

this mail will show up as coming from noreply@domain.com, it's the thing after the -f flag which makes that change.

this fifth parameter of the mail function fixes things quite nicely. Let me know if it works for you as well. Now if only you can get it to go from a consistent number each time, that would be really helpful.

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