Hello,

I am trying to use the mail() function, and I keep get the following error that says

SMTP server response: 550 5.7.1 Unable to relay for any e-mail.

I added the IP of the webserver in Exchange to allow relaying, but still I get this error. Does anyone know how to go about fixing this and allow an e-mail to be sent?

Thanks for your help,
Joe Barkawi

    Make sure your server is not also requiring authentication. If so, you would also have to provide a username/password. If you aren't the admin of this smtp server you might to check with the admin about relaying as there are other measures an admin could be taking to prevent this.

      What is in the php.ini or what does phpinfo(); show for the SMTP and sendmail_from? You can control this with PHP script using ini_set()

      Make sure your server is not also requiring authentication.

      Authenication as far as email goes is merely that it is a valid mailserver, in other words it does not look for passwords or any of that it looks for the fact that the email address is an authentic one such as microsoft.com etcetera, do not confuse authentication (validity) with authorization (authority)

        Since you are getting the relay error (smtp server is exchange???), I would assume that SMTP AUTH is not the issue (However, it IS a fact that some ISPs require STMP AUTH even for users within their netblock.) More than likely, your IP address is not within a netblock (range) that either your local smtp service or, in the case of your machine being a null client to another smtp server, that is accepted for relaying email. It's difficult to pull out the "smoking gun" without knowing more about your configuration. Does the server your PHP scipt is running on relay mail directly, or does it send mail to an intermediate server for relay (null client or smart host configuration?) Are you using 'SMTP = some_smtp_server' in your php.ini ? If the later, this may again just be a case of your servers IP not being in an acceptable range for relaying through "some_smtp_server." You should be relaying from your own machine or forwarding to your ISP's smtp server. You cannot relay through any SMTP server (unless that SMTP server is an open-relay....and that's a bad thing.)

          Write a Reply...