Skip to content
Advertisement

PHPMailer & GoDaddy

My problem is simple: send an email with PHPMailer, i have followed the rules of godaddy:

$mail = new PHPMailer();
$mail->IsSMTP(); 
$mail->SMTP_AUTH = false;
$mail->Port = 25;
$mail->Host = "relay-hosting.secureserver.net"; 
$mail->FromName = "mycomercial@mycomercialemail.com.br"; 

$mail->SMTPDebug = 2;
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("mygmailemail@gmail.com");

if(!$mail->Send()) {
    echo "Error: " . $mail->ErrorInfo;
} else {
    echo "Message has been sent";
}

This code is what i have seen in many of the forums i searched for, but i still can’t send the email, what i receive is:

2018-10-16 22:31:25 SMTP ERROR: Failed to connect to server: Connection refused (111) 2018-10-16 22:31:25 SMTP connect() failed

This is the server they recommend? why i cant connect? Thanks all for helping

Advertisement

Answer

Well, i have contacted the goDaddy support(very good), they said to use localhost when inside their servers, so i changed my code, still didnt work, but at least connected to the server and gave me the error: STARTTLS, searching in the web i found this solution: solution

$mail = new PHPMailer(true);
$mail->IsSMTP(); // Using SMTP.
$mail->SMTPDebug = 1;
$mail->SMTPAuth = false; // Enables SMTP authentication.
$mail->Host = "localhost"; // GoDaddy support said to use localhost
$mail->Port = 25;
$mail->SMTPSecure = 'none';

//havent read yet, but this made it work just fine
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);

$mail->AddReplyTo('comercial@email.com.br', 'Me');
$mail->AddAddress('my@gmail.com', 'Them'); 
$mail->SetFrom('comercial@email.com.br', 'Me');
$mail->Subject = 'PHPMailer Test Subject via smtp, basic with authentication';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->MsgHTML("Hi, this is an test email");
if(!$mail->Send()) {
    echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    echo "Message has been sent";
}

To finilize, they also gave me this script: Github to test the email sending in three diff ways, but the emails this script send may go to your spam(the first script goes normal), so they said that is necessary to configure something with the TXT records and DNS, this is the data the support gave me:

Add TXT record

Host:@

TXT value :v=spf1 a mx ptr include:secureserver.net -all

TTL: 1 hour

But i dont know for sure about this, unffotunatelly, i couldnt stay for this solution as i had to go to the doctor, thanks all for att.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement