I'm using Postfix, Roundcube 1.4.3 and devcot to receive and send emails on my vps server.
I'm able to receive emails but the errors are occurring when sending the email, the mail never reaches the destination.
Port 587 is what roundcube is using.
Roundcube error.log
[25-Dec-2021 07:18:35 +0000]: <669e8q7l> PHP Error: Connection refused (POST /?_task=mail&_unlock=loading1640416601599&_framed=1&_action=send)
[25-Dec-2021 07:18:35 +0000]: <669e8q7l> PHP Error: Failed to connect socket: Connection refused (POST /?_task=mail&_unlock=loading1640416601599&_framed=1&_action=send)
[25-Dec-2021 07:18:35 +0000]: <669e8q7l> SMTP Error: Connection failed: Failed to connect socket: Connection refused in /usr/share/roundcube/program/lib/Roundcube/rcube.php on line 1702 (POST /?_task=mail&_unlock=loading1640416601599&_framed=1&_action=send)
[25-Dec-2021 07:31:29 +0000]: <eb91q6is> PHP Error: Connection refused (POST /?_task=mail&_unlock=loading1640417491382&_framed=1&_action=send)
[25-Dec-2021 07:31:29 +0000]: <eb91q6is> PHP Error: Failed to connect socket: Connection refused (POST /?_task=mail&_unlock=loading1640417491382&_framed=1&_action=send)
Error I'm getting in Roundcube ui
SMTP Error (-1): Connection to server failed.
You don't have anything listening on the port you are trying to send mail through. You need to configure your postfix to listen and accept mails on port 587.
I'm using PHPMailer to send email via SMTP relay from my platform to send email. I've configured the authentication and everything, and also successfully sent test emails from the command line mail program on my server.
Initially, I had configured the SMTP relay via Postfix config and aimed to use the PHP mail() function. This was working fine from basic test scripts, but from my platform software, the emails were disappearing, despite the Postfix log saying the mail was relayed out successfully.
I replaced the usage of the mail() function with the latest version of PHPMailer, however the issue persists. I have captured a full log of a test send as an example:
2018-05-11 00:32:42 Connection: opening to smtp.api.createsend.com:587, timeout=300, options=array()
2018-05-11 00:32:43 Connection: opened
2018-05-11 00:32:43 SMTP INBOUND: "220 smtp.api.createsend.com ESMTP"
2018-05-11 00:32:43 SERVER -> CLIENT: 220 smtp.api.createsend.com ESMTP
2018-05-11 00:32:43 CLIENT -> SERVER: EHLO localhost
2018-05-11 00:32:43 SMTP INBOUND: "250-Hello smtp.api.createsend.com[1.129.185.25]"
2018-05-11 00:32:43 SMTP INBOUND: "250-PIPELINING"
2018-05-11 00:32:43 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2018-05-11 00:32:43 SMTP INBOUND: "250-8BITMIME"
2018-05-11 00:32:43 SMTP INBOUND: "250-STARTTLS"
2018-05-11 00:32:43 SMTP INBOUND: "250-AUTH PLAIN LOGIN"
2018-05-11 00:32:43 SMTP INBOUND: "250-AUTH=PLAIN LOGIN"
2018-05-11 00:32:43 SMTP INBOUND: "250 SIZE 20971520"
2018-05-11 00:32:43 SERVER -> CLIENT: 250-Hello smtp.api.createsend.com[1.129.185.25]250-PIPELINING250-ENHANCEDSTATUSCODES250-8BITMIME250-STARTTLS250-AUTH PLAIN LOGIN250-AUTH=PLAIN LOGIN250 SIZE 20971520
2018-05-11 00:32:43 CLIENT -> SERVER: STARTTLS
2018-05-11 00:32:43 SMTP INBOUND: "220 2.0.0 Ready to start TLS"
2018-05-11 00:32:43 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2018-05-11 00:32:43 CLIENT -> SERVER: EHLO localhost
2018-05-11 00:32:43 SMTP INBOUND: "250-Hello smtp.api.createsend.com[1.129.185.25]"
2018-05-11 00:32:43 SMTP INBOUND: "250-PIPELINING"
2018-05-11 00:32:43 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2018-05-11 00:32:43 SMTP INBOUND: "250-8BITMIME"
2018-05-11 00:32:43 SMTP INBOUND: "250-AUTH PLAIN LOGIN"
2018-05-11 00:32:43 SMTP INBOUND: "250-AUTH=PLAIN LOGIN"
2018-05-11 00:32:43 SMTP INBOUND: "250 SIZE 20971520"
2018-05-11 00:32:43 SERVER -> CLIENT: 250-Hello smtp.api.createsend.com[1.129.185.25]250-PIPELINING250-ENHANCEDSTATUSCODES250-8BITMIME250-AUTH PLAIN LOGIN250-AUTH=PLAIN LOGIN250 SIZE 20971520
2018-05-11 00:32:43 Auth method requested: UNSPECIFIED
2018-05-11 00:32:43 Auth methods available on the server: PLAIN,LOGIN
2018-05-11 00:32:43 Requested auth method not available:
2018-05-11 00:32:43 Auth method selected: LOGIN
2018-05-11 00:32:43 CLIENT -> SERVER: AUTH LOGIN
<snip>
2018-05-11 00:32:43 SMTP INBOUND: "235 2.7.0 Authentication successful"
2018-05-11 00:32:43 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2018-05-11 00:32:43 CLIENT -> SERVER: MAIL FROM:<###envelope_from_email_address#domain1###>
2018-05-11 00:32:43 SMTP INBOUND: "250 2.1.0 accepting mail from <###envelope_from_email_address#domain1###> OK"
2018-05-11 00:32:43 SERVER -> CLIENT: 250 2.1.0 accepting mail from <###envelope_from_email_address#domain1###> OK
2018-05-11 00:32:43 CLIENT -> SERVER: RCPT TO:<###to_email_address#domain2###>
2018-05-11 00:32:43 SMTP INBOUND: "250 2.1.0 I'll make sure <###to_email_address#domain2###> gets this"
2018-05-11 00:32:43 SERVER -> CLIENT: 250 2.1.0 I'll make sure <###to_email_address#domain2###> gets this
2018-05-11 00:32:43 CLIENT -> SERVER: DATA
2018-05-11 00:32:43 SMTP INBOUND: "354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>"
2018-05-11 00:32:43 SERVER -> CLIENT: 354 2.0.0 Go ahead. End your data with <CR><LF>.<CR><LF>
2018-05-11 00:32:43 CLIENT -> SERVER: Date: Fri, 11 May 2018 10:32:42 +1000
2018-05-11 00:32:43 CLIENT -> SERVER: To: ###to_email_address#domain2###
2018-05-11 00:32:43 CLIENT -> SERVER: From: ###from_email_address#domain3###
2018-05-11 00:32:43 CLIENT -> SERVER: Subject: ###email_subject###
2018-05-11 00:32:43 CLIENT -> SERVER: Message-ID: <0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA#localhost>
2018-05-11 00:32:43 CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.5 (https://github.com/PHPMailer/PHPMailer)
2018-05-11 00:32:43 CLIENT -> SERVER: MIME-Version: 1.0
2018-05-11 00:32:43 CLIENT -> SERVER: Content-Type: multipart/alternative;
2018-05-11 00:32:43 CLIENT -> SERVER: boundary="b1_0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA"
2018-05-11 00:32:43 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER: This is a multi-part message in MIME format.
2018-05-11 00:32:43 CLIENT -> SERVER: --b1_0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA
2018-05-11 00:32:43 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER:
<snip for plaintext email content>
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER: --b1_0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA
2018-05-11 00:32:43 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2018-05-11 00:32:43 CLIENT -> SERVER:
<snip for html email content>
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER: --b1_0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA--
2018-05-11 00:32:43 CLIENT -> SERVER:
2018-05-11 00:32:43 CLIENT -> SERVER: .
2018-05-11 00:32:43 SMTP INBOUND: "250 2.0.0 OK:ODJmM2I5YmEtMzU0My00M2ZjLWE5NzUtNTlkNzNkMjE0N2Ew"
2018-05-11 00:32:43 SERVER -> CLIENT: 250 2.0.0 OK:ODJmM2I5YmEtMzU0My00M2ZjLWE5NzUtNTlkNzNkMjE0N2Ew
2018-05-11 00:32:43 CLIENT -> SERVER: QUIT
2018-05-11 00:32:43 SMTP INBOUND: "221 2.0.0 Bye"
2018-05-11 00:32:43 SERVER -> CLIENT: 221 2.0.0 Bye
2018-05-11 00:32:43 Connection: closed
As it shows, PHPMailer successfully connects and authenticates using TLS, sends the email content, signs off without a hitch. However, this (and many other similar examples) don't appear in the SMTP provider's delivery logs. Additionally, I've been told by their customer support that these emails are never hitting their servers. Example response (this response was based on the above log):
Thank you for following up here, I'm afraid we don't have detailed enough logs to provide further information on this. Also, I can't see from the information you provided that we are responding with a message ID, I believe the message ID that appears in your log is generated by PHP Mailer and is not related to Campaign Monitor. I don't believe our server is responding to this attempt to send an email, which would indicate that the problem is with your implementation of PHP Mailer.
As the provider says, the issue here is with PHP Mailer. That doesn't make sense at all to me based on the logs, but I don't know enough to be able to diagnose what's going wrong and why these emails are disappearing. How can I troubleshoot the problem?
This delivery is entirely successful. Any issues after that are not down to your sending code. To find out what happened to the message, you would need to look at the mail logs on smtp.api.createsend.com (which is apparently Campaign Monitor).
PHPMailer creates the Message-ID header, as it should, since it's the responsibility of the MUA, in this case 0JtQSmGxTN2PuNR4zJx5iqS9FyZrLK5gL3zPLHwVCA#localhost, and you could improve this. It's falling back to localhost as the hostname, which suggests PHP on your server is not configured correctly and doesn't know its own hostname. You can either fix that in your PHP config, or set $mail->MessageID yourself (note the pattern that it must match).
The SMTP transaction ID (in this case ODJmM2I5YmEtMzU0My00M2ZjLWE5NzUtNTlkNzNkMjE0N2Ew), which is not the same as the message ID, is created by the receiving server and is usually used for internal tracking by the receiving server.
Incidentally it's the first time I've seen Campaign Monitor's transaction ID pattern, and it's different to others, so I've added it to PHPMailer. You will be able to retrieve it after sending by calling $mail->smtp->getLastTransactionID().
I am getting the error: Auth method requested UNKNOWN, when trying to send emails via smtp with smtp.office365.com.
Using the same password and username on https://smtp.office365.com/owa/ website successfully logs me into the account.
I have confirmed the username and password are correct.
PhpMailer v6 used ..Code is here https://pastebin.com/vteFTsCM
Kindly assist..
Below are the full error logs.
2017-09-25 08:22:48 Connection: opening to smtp.office365.com:587, timeout=300, options=array()
2017-09-25 08:22:48 Connection: opened
2017-09-25 08:22:49 SMTP INBOUND: "220 DB6PR0601CA0011.outlook.office365.com Microsoft ESMTP MAIL Service ready at Mon, 25 Sep 2017 08:22:48 +0000"
2017-09-25 08:22:49 SERVER -> CLIENT: 220 DB6PR0601CA0011.outlook.office365.com Microsoft ESMTP MAIL Service ready at Mon, 25 Sep 2017 08:22:48 +0000
2017-09-25 08:22:49 CLIENT -> SERVER: EHLO localhost
2017-09-25 08:22:49 SMTP INBOUND: "250-DB6PR0601CA0011.outlook.office365.com Hello [197.254.27.214]"
2017-09-25 08:22:49 SMTP INBOUND: "250-SIZE 157286400"
2017-09-25 08:22:49 SMTP INBOUND: "250-PIPELINING"
2017-09-25 08:22:49 SMTP INBOUND: "250-DSN"
2017-09-25 08:22:49 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2017-09-25 08:22:49 SMTP INBOUND: "250-STARTTLS"
2017-09-25 08:22:49 SMTP INBOUND: "250-8BITMIME"
2017-09-25 08:22:49 SMTP INBOUND: "250-BINARYMIME"
2017-09-25 08:22:49 SMTP INBOUND: "250-CHUNKING"
2017-09-25 08:22:49 SMTP INBOUND: "250 SMTPUTF8"
2017-09-25 08:22:49 SERVER -> CLIENT: 250-DB6PR0601CA0011.outlook.office365.com Hello [197.254.27.214]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2017-09-25 08:22:49 CLIENT -> SERVER: STARTTLS
2017-09-25 08:22:49 SMTP INBOUND: "220 2.0.0 SMTP server ready"
2017-09-25 08:22:49 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2017-09-25 08:22:50 CLIENT -> SERVER: EHLO localhost
2017-09-25 08:22:50 SMTP INBOUND: "250-DB6PR0601CA0011.outlook.office365.com Hello [197.254.27.214]"
2017-09-25 08:22:50 SMTP INBOUND: "250-SIZE 157286400"
2017-09-25 08:22:50 SMTP INBOUND: "250-PIPELINING"
2017-09-25 08:22:50 SMTP INBOUND: "250-DSN"
2017-09-25 08:22:50 SMTP INBOUND: "250-ENHANCEDSTATUSCODES"
2017-09-25 08:22:50 SMTP INBOUND: "250-AUTH LOGIN XOAUTH2"
2017-09-25 08:22:50 SMTP INBOUND: "250-8BITMIME"
2017-09-25 08:22:50 SMTP INBOUND: "250-BINARYMIME"
2017-09-25 08:22:50 SMTP INBOUND: "250-CHUNKING"
2017-09-25 08:22:50 SMTP INBOUND: "250 SMTPUTF8"
2017-09-25 08:22:50 SERVER -> CLIENT: 250-DB6PR0601CA0011.outlook.office365.com Hello [197.254.27.214]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2017-09-25 08:22:50 Auth method requested: UNKNOWN
2017-09-25 08:22:50 Auth methods available on the server: LOGIN,XOAUTH2
2017-09-25 08:22:50 Requested auth method not available:
2017-09-25 08:22:50 Auth method selected: LOGIN
2017-09-25 08:22:50 CLIENT -> SERVER: AUTH LOGIN
2017-09-25 08:22:50 SMTP INBOUND: "334 XXXXXXXXXXXXXXXXXXXXXXXXX"
2017-09-25 08:22:50 SERVER -> CLIENT: 334 XXXXXXXXXXXXXXXXXXXXXXXXX
2017-09-25 08:22:50 CLIENT -> SERVER: XXXXXXXXXXXXXXXXXXXXXXXXX==
2017-09-25 08:22:51 SMTP INBOUND: "334 XXXXXXXXXXXXXXXXXXXXXXXXX"
2017-09-25 08:22:51 SERVER -> CLIENT: 334 XXXXXXXXXXXXXXXXXXXXXXXXX
2017-09-25 08:22:51 CLIENT -> SERVER: XXXXXXXXXXXXXXXXXXXXXXXXX==
2017-09-25 08:22:58 SMTP INBOUND: "535 5.7.3 Authentication unsuccessful [DB6PR0601CA0011.eurprd06.prod.outlook.com]"
2017-09-25 08:22:58 SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful [DB6PR0601CA0011.eurprd06.prod.outlook.com]
2017-09-25 08:22:58 SMTP ERROR: Password command failed: 535 5.7.3 Authentication unsuccessful [DB6PR0601CA0011.eurprd06.prod.outlook.com]
SMTP Error: Could not authenticate.
2017-09-25 08:22:58 CLIENT -> SERVER: QUIT
2017-09-25 08:22:58 SMTP INBOUND: "221 2.0.0 Service closing transmission channel"
2017-09-25 08:22:58 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2017-09-25 08:22:58 Connection: closed
SMTP Error: Could not authenticate.
Message could not be sent.Mailer Error: SMTP Error: Could not authenticate.
I'm trying to send an email via SMTP using telnet. I have to authenticate (I'm interested now in AUTH LOGIN method). Here is output:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP service ready
ehlo localhost
250-localhost
250-STARTTLS
250-AUTH PLAIN LOGIN
250-PIPELINING
250 8BITMIME
auth login
334 VXNlcm5hbWU6
bXl1c2VybmFtZQ
334 UGFzc3dvcmQ6
bXlwYXNzd29yZA
535 invalid authentication
With example above all is fine - server understands my login and passwords (there are wrong but it's not important right now). Here is another example:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 localhost ESMTP service ready
ehlo localhost
250-localhost
250-STARTTLS
250-AUTH PLAIN LOGIN
250-PIPELINING
250 8BITMIME
auth login bXl1c2VybmFtZQ
334 UGFzc3dvcmQ6
bXlwYXNzd29yZA
500 Unrecognized command
My question is - am I able to send AUTH LOGIN user_name command and then password? Or should I always send just AUTH LOGIN and then separately user name and separately password?
Recently, I've been experiencing problems with my email setup using Emacs (24.4.2) + Gnus (0.12). It seems that the TSL connection is not working:
gnutls.c: [0] (Emacs) fatal error: The TLS connection was non-properly terminated.
gnutls.el: (err=[-110] The TLS connection was non-properly terminated.) boot: (:priority NORMAL :hostname smtp.me.com :loglevel 0 :min-prime-bits 256 :trustfiles nil :crlfiles nil :keylist nil :verify-flags nil :verify-error nil :callbacks nil)
smtpmail-send-it: Sending failed: 530 5.7.0 No STARTTLS command has been given.
Is it a Gnus or Openssl problem? How should I debug and fix it?
Here is the output of the smtp trace buffer:
220 nk11p00mm-asmtp003.example.com -- Server ESMTP (Oracle Communications Messaging Server 7u4-27.10(7.0.4.27.9) 64bit (built Jun 6 2014))
250-nk11p00mm-asmtp003.example.com
250-8BITMIME
250-PIPELINING
250-CHUNKING
250-DSN
250-ENHANCEDSTATUSCODES
250-EXPN
250-HELP
250-XADR
250-XSTA
250-XCIR
250-XGEN
250-XLOOP 098E7F59418D8F04E0C7135651497A4E
250-STARTTLS
250-NO-SOLICITING
250 SIZE 28311552
220 2.5.0 Go ahead with TLS negotiation.
Process smtpmail deleted
220 nk11p00mm-asmtp003.example.com -- Server ESMTP (Oracle Communications Messaging Server 7u4-27.10(7.0.4.27.9) 64bit (built Jun 6 2014))
MAIL FROM:<john.doe#example.com>
250-nk11p00mm-asmtp003.example.com
250-8BITMIME
250-PIPELINING
250-CHUNKING
250-DSN
250-ENHANCEDSTATUSCODES
250-EXPN
250-HELP
250-XADR
250-XSTA
250-XCIR
250-XGEN
250-XLOOP 098E7F59418D8F04E0C7135651497A4E
250-STARTTLS
250-NO-SOLICITING
250 SIZE 28311552
RCPT TO:<john.doe#example.com>
530 5.7.0 No STARTTLS command has been given.
QUIT
503 5.5.0 No MAIL FROM command has been issued.