0
votes

I am working on a website with a form that is used to send email with PHPMailer. i have a GoDaddy hosting plan linux. I have tried multiple ways without any success, some time ago it worked and now does not work.

Configuration 1 with Gmail

include_once('phpmailer/class.phpmailer.php');
include_once('phpmailer/class.smtp.php');



$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = false;
$mail->SMTPSecure = false; (I've tried the 2 options)
$mail->Host = "relay-hosting.secureserver.net";
$mail->Port = 25;
$mail->Username ='[email protected]';
$mail->Password = 'xxxxxxx';
$mail->Subject = 'Form from website'; 

$mail->AddAddress("[email protected]");
$mail->FromName   = "formsite"; 
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';

Log

Connection: opening to relay-hosting.secureserver.net:25, timeout=300, options=array ()

SMTP ERROR: Failed to connect to server: Connection refused (111) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Configuration 2 email from the same domain

$mail = new PHPMailer();
$mail->IsSMTP();
    $mail->SMTPSecure = true; // Enable TLS encryption, `ssl` also accepted
    $mail->SMTPAuth = false;  // Enable SMTP authentication
     $mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
$mail->Host = 'p3plcpnxxx.prod.phx3.secureserver.net';
$mail->Port = 465;
$mail->Username ='[email protected]';
$mail->Password = 'xxxxxxxx'; 
$mail->Subject = 'Form from website';
$mail->AddAddress("[email protected]");
$mail->FromName   = "formsite";
$mail->SMTPDebug = 3;
$mail->Debugoutput = 'html';

Log

SERVER -> CLIENT: 220-p3plcpnxxxx.prod.phx3.secureserver.net ESMTP Exim 4.89 #1 Thu, 14 Dec 2017 21:11:11 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

CLIENT -> SERVER: EHLO www.xxxxxx.com

SERVER -> CLIENT: 250-p3plcpnxxxx.prod.phx3.secureserver.net Hello p3plcpnxxxx.prod.phx3.secureserver.net [180.168.200.196]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250-CHUNKING250 HELP

1
You have not actually asked a question. Your first example looks like a firewall block - ask GoDaddy about that. Your second example is working fine, though SMTPSecure = true should be SMTPSecure = 'ssl'; Don't just make up values and expect it to work - read the docs and code if you're unsure. You should not need to disable cert verification; GoDaddy shouldn't be publishing bad certs, and you should have up to date CA certificates. You're using an old version of PHPMailer, and you've based your code on an obsolete example, so get the latest.Synchro

1 Answers

1
votes

To help others struggling with GoDaddy, these two variations worked for me:

Hosting: GoDaddy shared/cPanel

Sending "From:" a GMail address

PHPMailer version 6.0.5

  $mail = new PHPMailer;
  $mail->isSMTP();

  $mail->SMTPDebug = 2;

  $send_using_config = 1; // set to 1, 2, etc. to test different settings
  switch ($send_using_config):
    case 1:
      $mail->Host = 'localhost';
      $mail->Port = 25;
      $mail->SMTPSecure = FALSE;
      $mail->SMTPAuth = FALSE;
      $mail->SMTPAutoTLS = FALSE;
      break;
    case 2:
      # Host amnd Port info obtained from:
      #   Godaddy > cPanel Home > Email > cPanel Email > Mail Configuration > "Secure SSL/TLS Settings" > Outgoing Server
      $mail->Host = 'a2plcpnxyzw.prod.iad2.secureserver.net';
      $mail->Port = 465;
      $mail->SMTPSecure = 'ssl';
      $mail->SMTPAuth = FALSE;
      $mail->SMTPOptions = array(
          'ssl' => array(
            'verify_peer' => FALSE,
            'verify_peer_name' => FALSE,
            'allow_self_signed' => TRUE
          )
      );
      break;
  endswitch;

  $mail->Username = '[email protected]';
  $mail->Password = 'your_gmail_password';

  $mail->setFrom($from);
  $mail->addAddress($to);
  $mail->Subject = $subject;
  $mail->msgHTML($message);
  $mail->send();

These settings are based on the question posted here and modified with the advice from @Synchro on StackOverflow and GitHub. Thank you @Synchro!