Muhammad Irfan
Muhammad Irfan

Reputation: 1457

SMTP not working with php mailer class

I have two accounts:

[email protected]
[email protected]

and

Incoming POP3: pop.secureserver.net (995)
Outgoing SMTP: smtpout.secureserver.net (80, 3535, 25, 465)

These work using email clients like Thunderbird, post-box, etc, but not with php-mailer:

        error_reporting(0);
        require_once ("class.phpmailer.php");// PHP MAILER FOR SENDING EMAILS

        $mail = new PHPMailer();

        define('EMAIL_HOST','smtpout.secureserver.net');
        define('EMAIL_USER','[email protected]');
        define('EMAIL_PASSWORD','xxxxxxxx');

        $mail->IsSMTP();                    
        $mail->Port     = 465;              
        $mail->Host     = EMAIL_HOST;       
        $mail->Username = EMAIL_USER;       
        $mail->Password = EMAIL_PASSWORD;   
        $mail->SMTPAuth = true;             

        $mail->FromName = "Administrator";
        $mail->From = "Administrator";
        $mail->AddAddress($email); 
        $mail->WordWrap = 50;   
        $mail->IsHTML(true);    
        $mail->Subject  = "Seating Arrangements on Event";
        $mail->Body     = "Dear WeddingWire Customer";

        if($mail->Send()) return "true";        

        return  "false";

Upvotes: 3

Views: 6306

Answers (4)

Er. Anurag Jain
Er. Anurag Jain

Reputation: 1793

Using this info you configure phpmailer like this:

$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPDebug = 2; // enables SMTP debug
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier

I think this will be helpful for you. either it will be work or show the real issue comes in your mail. If this not work then please check some things

  1. Does your Host have permission to relay through the SMTP Host?
  2. Does your host require POP before SMTP?
  3. Does your Host require SMTP authentication?

Upvotes: 1

George
George

Reputation: 2950

Have you tried using $mailer->SmtpSend(); This tutorial seems to suggest you need to.

Upvotes: 0

gadhra
gadhra

Reputation: 21

From the server hosting this file, does calling smtpout.secureserver.net resolve correctly? Try pinging it and seeing if the IP address is what you expect

Barring that, I PHPMailer() uses exceptions if you pass it a "true" parameter, so try something like:

$mail = new PHPMailer(true);
try
{
    $mail->IsSMTP();                    
    $mail->Port     = 465;              
    $mail->Host     = EMAIL_HOST;       
    $mail->Username = EMAIL_USER;       
    $mail->Password = EMAIL_PASSWORD;   
    $mail->SMTPAuth = true;             

    $mail->FromName = "Administrator";
    $mail->From = "Administrator";
    $mail->AddAddress($email); 
    $mail->WordWrap = 50;   
    $mail->IsHTML(true);    
    $mail->Subject  = "Seating Arrangements on Event";
    $mail->Body     = "Dear WeddingWire Customer";
    $mail->Send();
} catch( phpmailerException $e ) {
    echo $e->errorMessage();
    exit(0);
}

That should at lease give you an insight into the error being thrown.

Upvotes: 0

Quaid
Quaid

Reputation: 333

have u tried $mail->SMTPSecure='ssl' ? some SMTP servers need this.

Check the error with $mail->ErrorInfo sometime gives a tip.

Upvotes: 7

Related Questions