Juan Solana
Juan Solana

Reputation: 157

PHPMailer works on localhost, but fails on server

My script runs perfect on my localhost on WAMP, but when I try to run it on my server it fails, I tried also to run it on another server and it sends me the same error. This is the error I get when running the script on the server:

> SMTP ERROR: Failed to connect to server: Connection timed out (110)
> SMTP connect() failed.

This is my PHPMailer configuration:

                require ('PHPMailer-master/PHPMailerAutoload.php');

                $alertvalue = $_GET["alert"];

                $mail = new PHPMailer();
                echo "<p> Instance created. </p>";
                $mail -> isSMTP();
                $mail -> Host = "ssl://smtp.gmail.com"; // I've also tried withou the ssl://
                $mail -> Port = 465; // I've also tried 587 and 25
                $mail -> SMTPAuth = true;
                $mail -> Username = '[email protected]';
                $mail -> Password = '-------------';
                $mail -> SMTPSecure = 'tls'; // I've also tried with ssl
                $mail -> SMTPDebug = 1;

                $mail -> From = '[email protected]';
                $mail -> FromName = '----------';
                $mail -> addAddress('[email protected]', '----');

Any idea why this is happenning? I've looked at several posts with a similar situation but I haven't been able to figure out my problem yet.

Upvotes: 0

Views: 1867

Answers (1)

DEEPAK MITTAL
DEEPAK MITTAL

Reputation: 141

Just comment $mail->IsSMTP(); ..I had same problem..On localhost its working and live server not working..After I commented $mail->IsSMTP(); this, Its working fine..Hopes so might be helpful for u it is

Upvotes: 3

Related Questions