skip to Main Content

Just recently and by accident, I found out that I cannot send emails to foreign sources beyond my server (I’ve been testing it with local Email addresses being installed at the same server). This is my code and I cannot send to (e.g.) gmail or yahoo.

$receiver = $emailadr;
$subj     = 'Auth';
$msg      = 'Thank you!';
$header = 'From: [email protected]' . "rn" . 
'Reply-To: [email protected]' . "rn" . 
'X-Mailer: PHP/' . phpversion() . "rn" . 'Content-type: text/html; charset=iso-8859-1';
mail($receiver, $subj, $msg, $header);

When (attempting) sending, it comes up with this:

: mail(): SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.

I’m using Plesk 12.5

2

Answers


  1. Looks like a problem of the mailserver. Your codes is on a shared hosting? Your provider probably has an anti-spam configuration (hopefully). You have to make sure that your sender address is existing. For testing, it’s also helpful if you send the message to yourself (if you didn’t already), this has more chances to work and then you can check the mail headers.

    On a average configured e-mail server, there are four ways of mail communication: (i assume your server is running somedomain.com and is providing @somedomain.com mails)

    • Incoming: Mails from [email protected] to @somedomain.com. These mails are normally simply accepted.
    • Outgoing: Mails from @somedomain.com to [email protected]. There mails are accepted if the origin IP address is in the local network (or the webserver). That’s what you want
    • Internal: Mails from @somedomain.com to @somedomain.com. That’s another option for you, if you send the message to yourself. Here you have the highest change that the mail arrives
    • Relay: Mails from [email protected] to [email protected]. This is what your server thinks you are doing. Relaying mails is normally denied except for authenticated users because it’s normally spam (and that’s what it tells you in the error message). Unfortunately, the standard PHP sendmail function doesn’t support authentication. Because of this, you need to add the sender address to the mailserver’s whitelist or (easier:) change it to an accepted internal address which changes your mail to an outgoing or internal one, depending on the receiver address.
    Login or Signup to reply.
  2. Error message is quite clear This mail server requires authentication

    You can create mail user in Plesk and use following PHP class to send mail with authentication:

    http://phpmailer.worxware.com/index.php?pg=tutorial#2

    Also you can try some cloud mail services like http://sendgrid.com/ they have nice PHP API library.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search