简体   繁体   English

无法使用 php 邮件 function 发送邮件

[英]cannot send mail using php mail function

Im trying to use PHP mail on my local computer, but its just not working.我试图在我的本地计算机上使用 PHP 邮件,但它只是不起作用。 I am using the standard script from the php website:我正在使用来自 php 网站的标准脚本:

PHP error I'm getting PHP 错误我得到

SMTP server response: 550 Error sending message: Error: FROM address is invalid

actual PHP实际 PHP

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

i downloaded a local mail server, argosoft.我下载了一个本地邮件服务器,argosoft。 it says the service URL is http://services.argosoft.com/RelayService/Service.asmx .它说服务 URL 是http://services.argosoft.com/RelayService/Service.asmx I assume this is what i put in php.ini.我假设这就是我在 php.ini 中放入的内容。

php ini. php ini。

 For Win32 only.
 SMTP = services.argosoft.com/RelayService/Service.asmx
 smtp_port = 25

I have had this error before, and I believe all you have to do is change the email webmaster@example.com to a real email.我以前遇到过这个错误,我相信您所要做的就是将 email webmaster@example.com更改为真正的 email。 Make sure you send it to a real email as well.确保您也将其发送到真正的 email。

Replace @example.com with real email addresses.将 @example.com 替换为真实的 email 地址。

and in PHP.ini set并在 PHP.ini 设置

SMTP = localhost

Apparently, a number of mail systems have trouble with the carriage return \r .显然,许多邮件系统在回车\r方面存在问题。 You might want to modify your $header to use only the new line character \n .您可能希望修改$header以仅使用换行符\n See if that works.看看这是否有效。

Also, you might want to try using the full From header:此外,您可能想尝试使用完整的 From header:

From: Some Name Here <real_email@notAnExample.com>

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

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