CentOS 6: cannot send email with PHPMailer but ok on laptop - centos

I am designing a website on aliyun.com. This website includes a function to send emails with PHPMailer. It perfectly works on my laptop (a Mac Book Air running XAMPP) but not on the live server (a fresh CentOS 6) with exactly the same php files (SMTP host, password, ...). Here is below the log I got from PHPMailer in verbose mode:
2015-04-08 02:59:42 Connection: opening to smtp.mywebsite.com:587, t=300, opt=array (
)
2015-04-08 02:59:42 Connection: opened
2015-04-08 02:59:42 SERVER -> CLIENT: 220 smtp.aliyun-inc.com MX AliMail Server(10.194.100.112)
2015-04-08 02:59:42 CLIENT -> SERVER: EHLO mywebsite.com
2015-04-08 02:59:42 SERVER -> CLIENT: 250-smtp.aliyun-inc.com
250-8BITMIME
250-AUTH=PLAIN LOGIN XALIOAUTH
250-AUTH PLAIN LOGIN XALIOAUTH
250-PIPELINING
250 DSN
2015-04-08 02:59:42 CLIENT -> SERVER: STARTTLS
2015-04-08 02:59:42 SERVER -> CLIENT: 220 Ready to start TLS
2015-04-08 02:59:42 CLIENT -> SERVER: QUIT
2015-04-08 02:59:44 SERVER -> CLIENT: ��:%4P���pGC#mLa+�%YF�l �0���I
2015-04-08 02:59:44 SMTP ERROR: QUIT command failed: ��:%4P���pGC#mLa+�%YF�l �0���I
2015-04-08 02:59:44 Connection: closed
2015-04-08 02:59:44 SMTP connect() failed.
Although I spent many hours on internet looking for a solution, I cannot figure out where the problem comes from... I am using the latest release of PHPMailer and the function mail in command lines works well (I mean I receive them), so where the problem could from?
Thanks a lot in advance!
Alplob

Perhaps, the openssl PHP extension is not installed on the Centos server. You should make sure the openssl extension is installed. To check the installed extensions, try the following command on Centos:
php -i
and look for openssl in the resulting text.

Related

SMTP relay not working on PHPMailer 6.0.5

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().

Why does VZWPIX.com (Email to MMS) defer 451 4.1.0? (EXIM Log)

I have a small texting service that is not blacklisted by cloudmark barracuda nor 100+ other respected anti-spam entities yet after roughly 1000 deliveries to vzwpix.com domain possible grey list happening? Also have exim.pl and exim.conf randomize 3 IP's for outgoing delivery only. SPF and DKIM correct through all IPs for reputation status. I searched for 2 weeks little to find last resort contact cloudfilter aka cloudmark. Thanx for your inputs not a huge deal at the moment.
PS: IP Reputation status clear since May 17'
Connecting to smtpin01-mms.vzw.a.cloudfilter.net [52.205.80.105]:25 from my.mailserver.ip.address ... connected
SMTP<< 220 vzw-ibgw-5003a.stratus.cloudmark.com cmsmtp ESMTP server ready
SMTP>> EHLO mail.mydomain.com
SMTP<< 250-vzw-ibgw-5003a.stratus.cloudmark.com hello [my.mailserver.ip.address], pleased to meet you
250-HELP
250-SIZE 30000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-STARTTLS
250 OK
SMTP>> STARTTLS
SMTP<< 220 2.0.0 Ready to start TLS
SMTP>> EHLO mail.mydomain.com
SMTP<< 250-vzw-ibgw-5003a.stratus.cloudmark.com hello [my.mailserver.ip.address], pleased to meet you
250-HELP
250-SIZE 30000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
SMTP>> MAIL FROM:<customer#mydomain.com> SIZE=1946
SMTP<< 452 4.1.0 <customer#mydomain.com> requested action aborted: try again later
LOG: MAIN
SMTP error from remote mail server after MAIL FROM:<customer#mydomain.com> SIZE=1946: 452 4.1.0 <customer#mydomain.com> requested action aborted: try again later
SMTP>> QUIT
SMTP(close)>>

Emacs (24.4.2) Gnus (0.12) TLS connection not working

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.

smtp server returns no auth methods

I am trying to set up my university smtp server with wanderlust/emacs, and on getting a repeated error decided to have a look via telnet.
the only trouble is, knowing next to nothing about smtp, I can't understand the output:
telnet pod51016.outlook.com 587
Trying 157.56.253.22...
Connected to pod51031.outlook.com.
Escape character is '^]'.
220 DBXPR06CA012.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 30 Sep 2014 16:44:11 +0000
ehlo test
250-DBXPR06CA012.outlook.office365.com Hello [129.234.0.21]
250-SIZE 78643200
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
I had expected to see an auth line as 250-AUTH LOGIN PLAIN --- II am just missing something? How do I see what authentication the server supports?
Alternatively, I have it working with thunderbird, so if anyone knows how to extract it from prefs.js that would do.
many thanks, and apologies for the lack of specificity in the question,
John
The server requires you to use establish a secure connection: Use STARTTLS, and the auth methods will appear.
You can test this with openssl:
openssl s_client -starttls smtp -connect server:587

Setting up Postfix/SMTP Auth service using ldap

How to configure the server to allow users to authenticate against the postfix and to send mail from any client software.  I think I am missing something small but I need HELP.  I have been working on this on and off for about 8 weeks now and cannot figure out my issue.
Telnet test from remote machine (My Laptop)
imac:~ jtolson $ echo -ne '\0sogo1\0sogo' | openssl enc -base64
AHNvZ28xAHNvZ28=
imac:~ jtolson $ telnet 10.1.2.130 25
Trying 10.1.2.130...
Connected to 10.1.2.130.
Escape character is '^]'.
220 *********************************
EHLO tcusit.com
250-tcusit.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN
250-AUTH=DIGEST-MD5 CRAM-MD5 NTLM LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH PLAIN AHNvZ28xAHNvZ28=
535 5.7.8 Error: authentication failed: authentication failure
From the /var/log/syslog on the server 10.1.2.130
Oct 17 11:21:41 sogo postfix/smtpd[14957]: connect from unknown[172.16.1.8]
Oct 17 11:21:59 sogo postfix/smtpd[14957]: warning: SASL authentication failure: Password verification failed
Oct 17 11:21:59 sogo postfix/smtpd[14957]: warning: unknown[172.16.1.8]: SASL PLAIN authentication failed: authentication failure
From the mail server file /etc/saslauthd.conf
ldap_servers: ldap://127.0.0.1:3389/
ldap_version: 3
ldap_auth_method: bind
ldap_search_base: dc=tcusit,dc=com
ldap_filter: (|(uid=%U)(cn=%U))
ldap_scope: sub
From the 10.1.2.130 mail server
root#sogo:~# testsaslauthd -u sogo1 -p sogo
0: OK "Success."
Given the testsaslauthd comes back with a "0: OK "Success." tells me that the ldap and saslauthd is working properly.  I know that the POSTFIX/SMTP is using SASL authentication and is failing on the password from the log file.  Postfix/SMTPD is configured with the SASL Authentication and the SASL Authentication through ldap is working given my testsaslauthd test.  What am I missing?  I am just trying to setup a simple mail server that I can use with remote clients from mobile, macs and windows. 
 Any guidance is appreciated.
It´s the solution
service saslauthd stop
rm -rf /var/spool/postfix/var/run/saslauthd
Edit /etc/default/saslauthdenter code hereSTART=yes
DESC="SASL Authentication Daemon"
NAME="saslauthd"
MECHANISMS="ldap"
MECH_OPTIONS=""
THREADS=5
OPTIONS="-r -V -c -m /var/spool/postfix/var/run/saslauthd"
dpkg-statoverride --force --update --add root sasl 755 /var/spool/postfix/var/run/
service saslauthd start