1

I am getting this error despite configuring php.ini to a valid send_from address. I know it is valid because it works when I send it from squirrel mail but when sending mail in php it will just not work. the invalid address presumably refers to the send_from address. so I can't see how it can think it's wrong. here is the php code:

$email="tobiasvogel1@googlemail.com";
$subject = "Your New Password";
$from="admin@dayshare.local";
$message = "Your new password is as follows:

xxxxxxxxxxxxxxxxxxxxxxxxxxx

This email was automatically generated.";

      if(!mail($email, $subject,$message,$from)){
         echo ("error");
      }else echo "success";

and in php.ini:

SMTP = localhost

sendmail_from = admin@dayshare.local
Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80
user1557515
  • 87
  • 2
  • 3
  • 14

5 Answers5

5

550 Delivery is not allowed to this address

This error means that the sender is trying to send an email to an address which he is not allowed to send to. This message is generated after hMailServer has checked the IP range settings. As an example, the default IP range configuration does not allow external users to send messages to other external users. This is to prevent people from using your server to send spam. So if an external user tries to send a message to another external user, he will get this message.

That is the meaning of the error you are getting. This is from the hMailServer Documentation.

Can you try if the following will work?

<?php
mail('tobiasvogel1@googlemail.com','Test Email','This is a test email.',"From: tobiasvogel1@googlemail.com");
?>

If it doesn't work, then it's probably due to a misconfiguration in your hMailServer and you would need to check your hMailServer Logs.

Community
  • 1
  • 1
rationalboss
  • 5,330
  • 3
  • 30
  • 50
  • thanks for the code I got the same problem so it probably is a mis coniguration but I can't for the life of me figure it out – user1557515 Sep 19 '12 at 13:52
2

The 4th parameter of the mail() function is not plain "from". In your code, you are only passing the email address without "From: " - The fourth parameter is for additional mail headers, so you have to format it like this:

mail($email, $subject,$message,"From: admin@dayshare.local\r\nX-Mailer: PHP");

I added another header as an example.

rationalboss
  • 5,330
  • 3
  • 30
  • 50
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
2

Try this, worked for me:

ini_set("sendmail_from", "info@yourdomain.com");
Cairnarvon
  • 25,981
  • 9
  • 51
  • 65
venky1893
  • 21
  • 1
0

You need quotes and a semi-colon:

$email="tobiasvogel1@googlemail.com";
Asciiom
  • 9,867
  • 7
  • 38
  • 57
BugFinder
  • 17,474
  • 4
  • 36
  • 51
  • probably because he should have gotten a different error (not the 550 address is not valid), something like "Parse error: syntax error, unexpected '@' in ..." Also, the line is missing a semi-colon. – rationalboss Sep 19 '12 at 13:18
  • 1
    This is why its important to paste your code, otherwise we pick on the errors that are in what you show us, not whats in the code you're using. – BugFinder Sep 19 '12 at 13:20
0

here is another solution - WAMP send Mail using SMTP localhost


KEEP IN MIND, everytime, after You change php.ini,

you must restart wamp (! ! !)

p.s. in php.ini, i have used:

SMTP = localhost 
smtp_port = 25 
sendmail_from = your_user@gmail.com

or if oyu cant edit php.ini, try to insert these lines in your php script.

ini_set("SMTP", "localhost");
ini_set("smtp_port", "25");
ini_set("sendmail_from", "your_user@gmail.com");
Community
  • 1
  • 1
T.Todua
  • 53,146
  • 19
  • 236
  • 237