4

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
dgamma3
  • 2,333
  • 4
  • 26
  • 47
  • I had what seems to be the same issue: http://stackoverflow.com/questions/1429317/strange-behavior-in-php-mail-function-address-does-not-exist – cwallenpoole Jun 02 '11 at 03:56

3 Answers3

2

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.

0

Replace @example.com with real email addresses.

and in PHP.ini set

SMTP = localhost
0xAli
  • 1,059
  • 10
  • 22
  • I get this error when i set SMTP to localhost: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() – dgamma3 Jun 02 '11 at 04:06
  • 1
    Run this in cmd, `netstat -an` do you see 127.0.0.1:25? – 0xAli Jun 02 '11 at 04:12
  • i see a lot of 127.0.0.1 but none with port 25. – dgamma3 Jun 02 '11 at 04:14
  • 1
    Then the server is not listening locally, make sure the server is running, or maybe you should try something like http://www.hmailserver.com/ – 0xAli Jun 02 '11 at 04:38
0

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>

Jason Gennaro
  • 34,535
  • 8
  • 65
  • 86
  • I know this is old, but I thought I'd share the knowledge anyway: According to RFC2822, header fields are to be seperated by a CRLF, that is "\r\n". – Anpan Dec 10 '13 at 09:15