Test email - Connection: closing due to error

New with phpList, trying to configure using HostGator. When I do the test email, I get this.

2024-05-05 22:10:28 Connection: opening to mail.mydomain.org:110, timeout=5, options=array()
2024-05-05 22:10:29 Connection: opened
2024-05-05 22:10:29 SMTP INBOUND: “+OK Dovecot ready.”
2024-05-05 22:10:29 SERVER → CLIENT: +OK Dovecot ready.
2024-05-05 22:10:29 Connection: closing due to error
2024-05-05 22:10:29 Connection: closed

Here are statements in config:

define(‘HASH_ALGO’, ‘sha256’);

$phpmailer = ‘1’;

define(“PHPMAILER_SECURE”,‘false’);

define(‘PHPMAILERHOST’,‘mail.mydomain.org:110’);

$phpmailer_smtpuser = ‘newsletter@mydomain.org’;
$phpmailer_smtppassword = ‘xxx1234!’;

define(‘PHPMAILER_SMTP_DEBUG’, 4);

I have tried all different ports, phpmailer_secure options.

My outlook that I use for mailmerge is configured with mail.mydomain.org utilizing port 110 and it works great.

Any ideas would be appreciated.

Thanks,
Owen

@Blastman You need to use the SMTP settings shown by Hostgator. Usually on the control panel page for email accounts there will be instructions on configuring your client.

Or send using the php mail() function instead of an smtp server by setting

define('PHPMAILERHOST', '');

Thank you for your response. Hostgator does have a knowledge base page on configuring email, Pop3, IMAP, SSL, RLS, secure, insecure. all that stuff. I have tried them all.

I have also contacted Hostgator and they have verified that I am using the correct SMTP servers with appropriate port.

As I said, for my Outlook email, I am using the same parameter in my config and it works fine.

Here is the latest debug from a test email. It is able to connect fine with the SMTP server, but fails after. How do I discover what the error was and why it closed?

2024-05-06 21:45:54 Connection: opening to mail.northwhidbeysportsmen.org:110/pop3/notls, timeout=5, options=array()
2024-05-06 21:45:54 Connection: opened
2024-05-06 21:45:54 SMTP INBOUND: “+OK Dovecot ready.”
2024-05-06 21:45:54 SERVER → CLIENT: +OK Dovecot ready.
**2024-05-06 21:45:54 Connection: closing due to error
2024-05-06 21:45:54 Connection: closed

I am not sure what you mean by " php mail() function instead of an smtp server by setting

define('PHPMAILERHOST', '');"

Seem like "define('PHPMAILERHOST', '');" statement is not defining a server.  So how does it know what to connect to?  

@Blastman You need to use the settings for SMTP, you are actually using the settings for POP3.

Remember this is a local install on Windows 10 with XAMPP
I noticed in the XAMPP control panel, with Apache, there is a config file with SMTP stuff.

I tried different SMTP setting according to hostgator. Here is the link to hostgator SMTP settings: https://www.hostgator.com/help/article/email-connection-settings

Why is POP3 not a solution? It works fine for outlook and mailmerge?

Here is the results of different options.

Config:

define(‘HASH_ALGO’, ‘sha256’);

// SMTP NO SSL Unsecure

$phpmailer = ‘1’;

define(“PHPMAILER_SECURE”,‘false’);

define(‘PHPMAILERHOST’,‘mail.mydomain.org’);

$phpmailer_smtpuser = ‘newsletter@mydomain.org’;

$phpmailer_smtppassword = ‘Mypassword!’;

define(“PHPMAILERPORT”, ‘25’);

define(‘PHPMAILER_SMTP_DEBUG’, 4);

Debug Messages:

2024-05-08 20:40:56 Connection: opening to mail.mydomain.org:25, timeout=5, options=array()
2024-05-08 20:40:56 Connection: opened
2024-05-08 20:41:02 SMTP INBOUND: “220-cloud265.hostgator.com ESMTP Exim 4.96.2 #2 Wed, 08 May 2024 15:41:02 -0500”
2024-05-08 20:41:02 SMTP INBOUND: “220-We do not authorize the use of this system to transport unsolicited,”
2024-05-08 20:41:02 SMTP INBOUND: “220 and/or bulk e-mail.”
2024-05-08 20:41:02 SERVER → CLIENT: 220-cloud265.hostgator.com ESMTP Exim 4.96.2 #2 Wed, 08 May 2024 15:41:02 -0500 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.
2024-05-08 20:41:02 CLIENT → SERVER: EHLO localhost
2024-05-08 20:41:02 SMTP INBOUND: “250-cloud265.hostgator.com Hello localhost [172.56.106.212]”
2024-05-08 20:41:02 SMTP INBOUND: “250-SIZE 52428800”
2024-05-08 20:41:02 SMTP INBOUND: “250-8BITMIME”
2024-05-08 20:41:02 SMTP INBOUND: “250-PIPELINING”
2024-05-08 20:41:02 SMTP INBOUND: “250-PIPECONNECT”
2024-05-08 20:41:02 SMTP INBOUND: “250-AUTH PLAIN LOGIN”
2024-05-08 20:41:02 SMTP INBOUND: “250-STARTTLS”
2024-05-08 20:41:02 SMTP INBOUND: “250 HELP”
2024-05-08 20:41:02 SERVER → CLIENT: 250-cloud265.hostgator.com Hello localhost [172.56.106.212]250-SIZE 52428800250-8BITMIME250-PIPELINING250-PIPECONNECT250-AUTH PLAIN LOGIN250-STARTTLS250 HELP
2024-05-08 20:41:02 CLIENT → SERVER: STARTTLS
2024-05-08 20:41:02 SMTP INBOUND: “220 TLS go ahead”
2024-05-08 20:41:02 SERVER → CLIENT: 220 TLS go ahead
2024-05-08 20:41:02 Connection failed. Error #2: stream_socket_enable_crypto(): Peer certificate CN=*.hostgator.com' did not match expected CN=mail.mydomain.org’ [C:\xampp\htdocs\lists\admin\PHPMailer6\src\SMTP.php line 467]
SMTP Error: Could not connect to SMTP host. Connection failed. stream_socket_enable_crypto(): Peer certificate CN=*.hostgator.com' did not match expected CN=mail.mydomain.org
2024-05-08 20:41:03 CLIENT → SERVER: QUIT
2024-05-08 20:41:03
2024-05-08 20:41:03
2024-05-08 20:41:03
2024-05-08 20:41:03 Connection: closed
SMTP connect() failed. Troubleshooting · PHPMailer/PHPMailer Wiki · GitHub

****These statement when test email is sent, there is no return, just spins.

Config – SSL with Port 465

define(‘HASH_ALGO’, ‘sha256’);

//mail server statements added

$phpmailer = ‘1’;

define(“PHPMAILER_SECURE”,‘AUTO’);

define(‘PHPMAILERHOST’,‘mail.mydomain.org’);

$phpmailer_smtpuser = ‘newsletter@mydomain.org’;

$phpmailer_smtppassword = ‘Mypassword!’;

define(“PHPMAILERPORT”, ‘465’);

define(‘PHPMAILER_SMTP_DEBUG’, 4);

****These statements are identical from about with exception of SSL instead of AUTO – no return

define(‘HASH_ALGO’, ‘sha256’);

//mail server statements added

$phpmailer = ‘1’;

define(“PHPMAILER_SECURE”,‘SSL’);

define(‘PHPMAILERHOST’,‘mail.mydomain.org’);

$phpmailer_smtpuser = ‘newsletter@mydomain.org’;

$phpmailer_smtppassword = ‘Mypassword!’;

define(“PHPMAILERPORT”, ‘465’);

define(‘PHPMAILER_SMTP_DEBUG’, 4);

****These statements are identical from about with exception of SSL instead of AUTO – no return

//mail server statements added

$phpmailer = ‘1’;

define(“PHPMAILER_SECURE”,‘IMAP’);

define(‘PHPMAILERHOST’,‘mail.mydomain.org’);

$phpmailer_smtpuser = ‘newsletter@mydomain.org’;

$phpmailer_smtppassword = ‘Mypassword!’;

define(“PHPMAILERPORT”, ‘143’);

define(‘PHPMAILER_SMTP_DEBUG’, 4);

false is a php keyword so should not be in quotes

When copying code or debug output please use the preformatted toolbar button </> to make it readable.

Thank you Duncanc, that worked. I very much appreciate the help. I am sure I will have more questions, I need to setup a template, throttling and ability to attach files. I will look in the extended config for the proper statements.