0

I've been trying for quite a while now, and I can't get phpmailer working with smtp. I've been testing here http://smtper.sweetylife.com/ to see if my smtp was working at all, and on this site I could connect without any problems. My phpmailer settings are:

    $mail   = new PHPMailer();
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host       = "mail.mydomain.com"; // SMTP Server
    $mail->SMTPDebug  = 2; // Debugmode
    $mail->SMTPAuth   = true; // enable SMTP authentication
    $mail->SMTPSecure = "tls";
    $mail->Port       = 587; // set the SMTP port for the GMAIL
    $mail->Username   = "[email protected]"; // SMTP account username
    $mail->Password   = "password";        // SMTP account password
    //$mail->SetFrom("[email protected]", "First Last");
    $mail->AddReplyTo("[email protected]","First Last");
    $mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";
    //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
    $mail->Body       = "demo mail";
    $address = "[email protected]";
    $mail->AddAddress($address, "John Doe");
    if(!$mail->Send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    else{
        echo "Message sent!";
    }

But it's not working. I get the following error:

SMTP -> FROM SERVER: 220 helios.web.xyn-ta.net ESMTP Exim 4.77 Mon, 14 May 2012 11:47:16 +0200
SMTP -> FROM SERVER: 250 helios.web.xyn-ta.net Hello localhost.localdomain [77.243.225.73]
SMTP -> FROM SERVER: 250 OK
SMTP -> FROM SERVER: 550 relay not permitted, authentication required
SMTP -> ERROR: RCPT not accepted from server: 550 relay not permitted, authentication required
SMTP -> FROM SERVER: 503-All RCPT commands were rejected with this error:
503-relay not permitted, authentication required
503 valid RCPT command must precede DATA
SMTP -> ERROR: DATA command not accepted from server: 503-All RCPT commands were rejected with this error:
503-relay not permitted, authentication required
503 valid RCPT command must precede DATA
SMTP -> FROM SERVER: 221 helios.web.xyn-ta.net closing connection
Mailer Error:

I have no idea what I've been doing wrong, does anyone have a solution to fix this?

1 Answer 1

1

This line is the problem:

SMTP -> FROM SERVER: 550 relay not permitted, authentication required

Your mailserver needs to to log in, and the password credentials you're supplying aren't being accepted. You should speak to the postmaster and make sure that you have the right username and password.

Failing that, try logging on to the SMTP server from the command line using the details in your script, and see if that generates any errors.

2
  • 1
    Yes, I know, but I've tested the server and login at smtper.sweetylife.com and everything worked instantly, using exactly the same in my script, it doesn't work.
    – user936965
    Commented May 16, 2012 at 13:02
  • So the same code is running on two different servers - it works on the one, but fails on the other? In which case, it'll be a server configuration issue - I imagine that the mailserver you're trying to connect to doesn't accept connections from third party servers. Speak to the postmaster there, and see if you can get the second server added to the list of servers the mailserver will accept connections from.
    – andrewsi
    Commented May 16, 2012 at 13:26