Here is my code:
<?php
mail('myemail@gmail.com','Test','Test');
?>
When sending to a non-company address, I get the following error:
Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay in C:\inetpub\wwwroot\internal_tools\include\mail.php on line 2
When switching the email address to my work email, it works just fine. My PHP.ini looks fine, too:
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
SMTP = PCMAIL1.mycompany.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = no-reply@mycompany.com
Even have the site set up in IIS7:
Any ideas?
You need to check your Smtp provider's policy. Or you need to check your Smtp server configuration (if this server deliver the emails directly)
To prevent abuse for sending spam, many email servers require that the client be authenticated as a legitimate user before relaying mail (forwarding it to the recipient's email server). You have specified credentials in IIS; however, PHP does not make use of them.
Here are your options:
mail()
function, use one of the existing PHP mailer libraries that supports SMTP authentication (PEAR Mail, phpmailer, Swift Mailer, etc.).sendmail_path
accordingly.