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.
Related
What I have is a relatively simple Perl script that will be given a string of json data, parse out specific properties and pretty-print the rest, wrap it all up in an email and send it out via my mail server. It's been two decades since I wrote any Perl but I'm fairly confident my code is alright.
Unfortunately, the script fails when it goes to authenticate to the postfix daemon via submission. It doesn't actually fail to authenticate. From the postfix logs it doesn't appear to even attempt to authenticate. After the server responds to the second EHLO (EHLO->STARTTLS->EHLO) the script appears to just abruptly disconnect. Is there some trick to making Net::SMTP authenticate that I'm missing here?
The resulting output is:
Net::SMTP>>> Net::SMTP(3.11)
Net::SMTP>>> Net::Cmd(3.11)
Net::SMTP>>> Exporter(5.73)
Net::SMTP>>> IO::Socket::IP(0.39)
Net::SMTP>>> IO::Socket(1.40)
Net::SMTP>>> IO::Handle(1.40)
Net::SMTP=GLOB(0x55d6336b7108)<<< 220 mx.example.net ESMTP Postfix (Ubuntu)
Net::SMTP=GLOB(0x55d6336b7108)>>> EHLO tiphares.example.net
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-mx.example.net
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-PIPELINING
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-SIZE 10240000
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-ETRN
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-STARTTLS
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-8BITMIME
Net::SMTP=GLOB(0x55d6336b7108)<<< 250-DSN
Net::SMTP=GLOB(0x55d6336b7108)<<< 250 SMTPUTF8
Net::SMTP=GLOB(0x55d6336b7108)>>> STARTTLS
Net::SMTP=GLOB(0x55d6336b7108)<<< 220 2.0.0 Ready to start TLS
Net::SMTP::_SSL=GLOB(0x55d6336b7108)>>> EHLO tiphares.example.net
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-mx.example.net
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-PIPELINING
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-SIZE 10240000
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-ETRN
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-AUTH PLAIN LOGIN
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-8BITMIME
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250-DSN
Net::SMTP::_SSL=GLOB(0x55d6336b7108)<<< 250 SMTPUTF8
Can't Authenticate:
mx.example.net
PIPELINING
SIZE 10240000
ETRN
AUTH PLAIN LOGIN
ENHANCEDSTATUSCODES
8BITMIME
DSN
SMTPUTF8
SASL(0): successful result: at /usr/local/sbin/suricata-alert-mail.pl line 134.
It's worth noting that other mail clients (ie. Thunderbird) have no issue with sending mail using the same server and port.
UPDATE: I've come to the conclusion there is nothing wrong with my code. So, as Steffen Ullrich alluded to in the comments, I suspect this is an issue with my environment.
These are my installed modules according to cpan -l.
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)>>
#!perl
use warnings;
use strict;
use Net::SMTP;
my $smtpserver = 'server';
my $smtpport = 25;
my $smtpuser = 'username';
my $smtppassword = 'password';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
die "Could not connect to server!\n" unless $smtp;
$smtp->auth($smtpuser, $smtppassword);
$smtp->mail('sender#example.com');
$smtp->to('mymail#gmail.com');
$smtp->data();
$smtp->datasend("To: mymail\#gmail.com\n");
$smtp->datasend("bla bla bla ... \n");
$smtp->quit;
When I execute this code I got the below output. I don't have much more knowledge about perl but the project is Perl, thus I must do it this way.
What is happening below: I do not understand it personally.
Net::SMTP>>> Net::SMTP(2.29)
Net::SMTP>>> Net::Cmd(2.26)
Net::SMTP>>> Exporter(5.58)enter code here
Net::SMTP>>> IO::Socket::INET(1.27)
Net::SMTP>>> IO::Socket(1.28)
Net::SMTP>>> IO::Handle(1.24)
Net::SMTP=GLOB(0x7a6280)<<< 220 server ESMTP Sendmail 8.13.1/8.13.1; Sun, 6 Dec 2015 19:34:41 +0530
Net::SMTP=GLOB(0x7a6280)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x7a6280)<<< 250-server Hello localhost.localdomain [127.0.0.1], pleased to meet you
Net::SMTP=GLOB(0x7a6280)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x7a6280)<<< 250-PIPELINING
Net::SMTP=GLOB(0x7a6280)<<< 250-8BITMIME
Net::SMTP=GLOB(0x7a6280)<<< 250-SIZE
Net::SMTP=GLOB(0x7a6280)<<< 250-DSN
Net::SMTP=GLOB(0x7a6280)<<< 250-ETRN
Net::SMTP=GLOB(0x7a6280)<<< 250-AUTH GSSAPI DIGEST-MD5 CRAM-MD5
Net::SMTP=GLOB(0x7a6280)<<< 250-DELIVERBY
Net::SMTP=GLOB(0x7a6280)<<< 250 HELP
Net::SMTP=GLOB(0x7a6280)>>> MAIL FROM:<sendermail>
Net::SMTP=GLOB(0x7a6280)<<< 250 2.1.0 <sendermail>... Sender ok
Net::SMTP=GLOB(0x7a6280)>>> RCPT TO:<receipient mail>
Net::SMTP=GLOB(0x7a6280)<<< 250 2.1.5 <recipient mail>... Recipient ok
Net::SMTP=GLOB(0x7a6280)>>> DATA
Net::SMTP=GLOB(0x7a6280)<<< 354 Enter mail, end with "." on a line by itself
Net::SMTP=GLOB(0x7a6280)>>> To: mymail#gmail.com
Net::SMTP=GLOB(0x7a6280)>>> .
Net::SMTP=GLOB(0x7a6280)<<< 250 2.0.0 tB6EJbum025820 Message accepted for delivery
Net::SMTP=GLOB(0x7a6280)>>> QUIT
Net::SMTP=GLOB(0x7a6280)<<< 221 2.0.0 server closing connection
I will be very grateful for any help — thanks in advance.
I don't understand the error outputted
You didn't show us any error. As you can see, the server said "Message accepted for delivery".
The missing ->dataend might mean you are sending an empty email, though.
What is happening below
An email message is being sent. As well, messages to help you debug problems are being outputted since you requested these using Debug => 1.
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
SO.
I'm failing at sending mail from my Perl script. This is what my code looks like:
use Net::SMTP;
$smtp = Net::SMTP->new("smtpserver.mydomain.com");
$smtp->mail("myemail\#mydomain.com");
$smtp->to("myemail\#mydomain.com");
$smtp->data();
$smtp->datasend("From: myemail\#mydomain.com\n");
$smtp->datasend("To: myemail\#mydomain.com\n");
$smtp->datasend("Subject: Test message\n");
$smtp->datasend("Just a test message.\n");
$smtp->dataend();
$smtp->quit;
This is what the debug option throws:
Net::SMTP>>> Net::SMTP(2.31)
Net::SMTP>>> Net::Cmd(2.29)
Net::SMTP>>> Exporter(5.64_03)
Net::SMTP>>> IO::Socket::INET(1.31)
Net::SMTP>>> IO::Socket(1.32)
Net::SMTP>>> IO::Handle(1.31)
Net::SMTP=GLOB(0x1d1a06c)<<< 220 ESMTP Postfix
Net::SMTP=GLOB(0x1d1a06c)>>> EHLO localhost.localdomain
Net::SMTP=GLOB(0x1d1a06c)<<< 250-
Net::SMTP=GLOB(0x1d1a06c)<<< 250-PIPELINING
Net::SMTP=GLOB(0x1d1a06c)<<< 250-SIZE
Net::SMTP=GLOB(0x1d1a06c)<<< 250-ETRN
Net::SMTP=GLOB(0x1d1a06c)<<< 250-STARTTLS
Net::SMTP=GLOB(0x1d1a06c)<<< 250-ENHANCEDSTATUSCODES
Net::SMTP=GLOB(0x1d1a06c)<<< 250-8BITMIME
Net::SMTP=GLOB(0x1d1a06c)<<< 250 DSN
Net::SMTP=GLOB(0x1d1a06c)>>> MAIL FROM:<myemail#mydomain.com>
Net::SMTP=GLOB(0x1d1a06c)<<< 250 2.1.0 Ok
Net::SMTP=GLOB(0x1d1a06c)>>> RCPT TO:<myemail#mydomain.com>
Net::SMTP=GLOB(0x1d1a06c)<<< 450 4.7.1 <localhost.localdomain>: Helo command rejected: Service temporarily unavailable
Net::SMTP=GLOB(0x1d1a06c)>>> DATA
Net::SMTP=GLOB(0x1d1a06c)<<< 554 5.5.1 Error: no valid recipients
Net::SMTP=GLOB(0x1d1a06c)>>> From: myemail#mydomain.com
Net::SMTP=GLOB(0x1d1a06c)>>> To: myemail#mydomain.com
Net::SMTP=GLOB(0x1d1a06c)>>> Subject: Test message
Net::SMTP=GLOB(0x1d1a06c)>>> Just a test message.
Net::SMTP=GLOB(0x1d1a06c)>>> .
Net::SMTP=GLOB(0x1d1a06c)<<< 221 2.7.0 Error: I can break rules, too. Goodbye.
Net::SMTP=GLOB(0x1d1a06c)>>> QUIT
The interesting part is that the SMTP server replies with 250 OK when I talk directly to it and I receive the mail just fine:
220 ESMTP Postfix
MAIL FROM:<myemail#mydomain.com>
250 2.1.0 Ok
RCPT TO:<myemail#mydomain.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Just a test message.
.
250 2.0.0 Ok: queued as B68672C02B
Does someone have some light to shed?
Thanks in advance.
Just posting this as an answer instead so that it can be accepted as the answer, as requested by triplee.
Something might be wrong in your domain setup.
also add $smtp->datasend("\n"); underneath $smtp->datasend("Subject: Test message\n"); in a new line, else it will not show mesage text.
like this.
$smtp->datasend("Subject: Test message\n");
$smtp->datasend("\n");
$smtp->datasend("Just a test message.\n");
The SMTP server (postfix) "does not like" hostname used in EHLO command but rejects it in reply to RCPT TO: command.
>>> MAIL FROM:<myemail#mydomain.com>
<<< 250 2.1.0 Ok
....
>>> RCPT TO:<myemail#mydomain.com>
<<< 450 4.7.1 <localhost.localdomain>: Helo command rejected: Service temporarily unavailable
You can make Net::SMTP use another hostname in HELO/EHLO command by passing Hello parameter to new.
$smtp = Net::SMTP->new('smtpserver.mydomain.com', Hello => 'host.example.net');