I'm using wamp server and trying to send email with the PHP function mail('me@ISPdomain.com','my subject','my body');
,
with the following settings in php.ini
:
SMTP = 'ISP's SMTP server'
smtp_port = 25
But I get the message:
Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Relaying not allowed. Please use SMTP Authentication.
How can this be solved?
Your ISP's mail servers do not allow "relaying", which is a good thing as otherwise they would end up moving a lot of spam.
http://en.wikipedia.org/wiki/Open_mail_relay
To be able to utilize your ISP's mail servers you need to authenticate first with a username and password.
You can try a hack of that php.ini line that goes like this:
SMTP = 'username:password@ISP's SMTP server address'
This is not guaranteed to work as this option requires a non-standard modification or option to be set on the mail server.
Your other option is to simply run your own local proxy mail server that requires no authentication, which will then either send the mail directly to the recipient's mail server, or via an authenticated connection to your mail server.
I don't know what is recommended to be used with WampServer, but with WampDeveloper Pro the recommended local mail servers are:
You should see the features and requirements of each one. I believe one of them can interfere with MySQL (as the installer will try to place its own copy of it).
The ISPdomain.com SMTP server is probably complaining that your connection is too basic for its anti-spam rules.
As the error message says, you need to use SMTP authentication for that server.
This is not possible using PHP's built-in SMTP capabilities.
The easiest way is to use a pre-made mailer class like Swiftmailer. Here is an example how to do it.