PHP Mailer error: The message could not be sent. Sender error: SMTP connect () error

Here is my code:

require 'phpmailertesting/PHPMailerAutoload.php';

$mail = new PHPMailer;

//$mail->SMTPDebug = 3;                               // Enable verbose debug output

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'send.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'myemailhidden';                 // SMTP username
$mail->Password = 'mypasswordhidden';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also     accepted
$mail->Port = 465;                                    // TCP port to connect to

$mail->From = 'myemailhidden';
$mail->FromName = 'My Name';
$mail->addAddress('example@example.com');               // Name is optional

$mail->addCC('cc@example.com');
$mail->addBCC('bcc@example.com');

//$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->isHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}

      

I tried changing the port and secure connection type to "TSL" and "SSL" and nothing. I've already looked at the answers and none of them solved it. Are there any answers? Thanks to

I turned on the SMTP debugger and this is what it said: "Connection: open at ssl: //send.one.com: 465, t = 300, opt = array () 2014-12-15 15:46:40 SMTP ERROR : Failed to connect to server: connection timed out (110) 2014-12-15 15:46:40 SMTP connect () error "

+3


source to share


3 answers


Your hosting company, one.com, is blocking outgoing mail ports to intentionally restrict malicious PHP scripts. The address is send.one.com

intended for external email clients such as your mobile phone, email client, etc., not for internal mailing scripts from your site.

According to their support document regarding sending emails from your site, you should change the host to your internal SMTP address mailout.one.com

- since this is an internal relay, you should also use port 25 and disable any security like TLS or SSL. You must also disable authentication.



Here's the correct configuration:

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'mailout.one.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = false; // Authentication must be disabled
$mail->Username = 'myemailhidden';
$mail->Password = ''; // Leave this blank
$mail->Port = 25;                                    // TCP port to connect to

      

+5


source


Other solutions didn't work for me; this:

$mail->isSMTP();
$mail->Host = 'mailout.one.com';
$mail->SMTPAuth = false;                            // disable SMTP authentication
$mail->Username = '[your one.com-email]';
$mail->Password = '[your one.com-email password]';
$mail->SMTPSecure = '';                            // leave this blank!
$mail->Port = 25;   

      



Let me know if this helped you!

0


source


New to SO so can't vote for you @sjagr

Had this problem, and as I use one.com, there was no big problem with the solution from @sjagr :)

You can try this complete output in your file and don't forget to link the required docs.

<?php

require 'PHPMailerAutoload.php';

$mail = new PHPMailer;
//$mail->SMTPDebug = 3;
$mail->isSMTP();
$mail->Host       = "mailout.one.com";
$mail->SMTPAuth   = false;
$mail->Port = 25;
$mail->From = 'your@domain.se';
$mail->FromName = 'Mailer';
$mail->addAddress('sendtothis@domain.se');
$mail->addReplyTo('ireply@domain.se', 'Information');
$mail->addBCC('bcc@example.com');
$mail->isHTML(true);
$mail->Subject = 'Here is the subject';
$mail->Body    = 'hejehej';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {

    echo 'Message could not be sent.';
    //echo 'Mailer Error: ' . $mail->ErrorInfo;

} else {

    echo 'Message has been sent, ja e fan inte tom';

} ?>

      

-1


source







All Articles