cannot send mail using php mail function

偶尔善良 提交于 2019-12-07 11:02:34

问题


Im trying to use PHP mail on my local computer, but its just not working. I am using the standard script from the php website:

PHP error I'm getting

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

actual 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. it says the service URL is http://services.argosoft.com/RelayService/Service.asmx . I assume this is what i put in php.ini.

php ini.

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

回答1:


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. Make sure you send it to a real email as well.




回答2:


Replace @example.com with real email addresses.

and in PHP.ini set

SMTP = localhost



回答3:


Apparently, a number of mail systems have trouble with the carriage return \r. You might want to modify your $header to use only the new line character \n. See if that works.

Also, you might want to try using the full From header:

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



来源:https://stackoverflow.com/questions/6210156/cannot-send-mail-using-php-mail-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!