简体   繁体   English

使用PHP邮件功能发送文本消息(参数“发件人”无效)

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

I am working with the mail function in PHP. 我正在使用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). 当发送到我的AOL电子邮件帐户时,此PHP函数正常工作,但是当我尝试将其发送到我的手机号码(cell number)@ vtext.com时,邮件已传递,但发件人的地址显示为(myusername)@ box489.bluehost.com,而不是“发件人”参数(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). 但是,当我通过在线Webmail应用手动将消息发送到手机时,发件人地址显示正确(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. 电信公司使用来自cisco的诸如senderbase.com之类的服务,当他们收到消息时,将要检查信誉,spf记录,rdns以及可能的更多信息。 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. 一段时间前,我创建了一个短信系统,最终使用PEAR邮件包通过smtp在邮件服务器上对电子邮件地址进行身份验证,然后发送邮件...甚至您可能正在从真实的电子邮件中发送邮件, mail()函数将从网络服务器的IP发送而不是从邮件服务器发送,它们也会对其进行检查。

such an annoying problem, isn't it? 这样烦人的问题,不是吗? here's a solution i came across finally :) 这是我终于遇到的解决方案:)

-- -

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

mail($to, $subject, $message, $headers, '-fnoreply@domain.com'); 邮件($ 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. 该邮件将显示为来自noreply@domain.com,这是-f标志后面的内容。

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. 现在,如果您每次都能使它取一个一致的数字,那将非常有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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