Unable to send mail with the mail command

0

I am unable to cause the 'mail' command to send mail from my linux ubuntu 15.10 computer. File 'mail.log' typically reports "Connection timed out".

I issue the command: 'mail -s "my subject" recipient@domain.com < filename', where 'filename' is a file containing my message.

Specifically, the log reports:

Jan 5 12:29:53 pegasus postfix/smtp[9006]: connect to mx01.gmx.com[74.208.5.27]:25: Connection timed out
Jan 5 12:30:23 pegasus postfix/smtp[9006]: connect to mx00.gmx.com[74.208.5.4]:25: Connection timed out

I suspect that my ISP (verizon) is blocking port 25 and thus causing the problem: however, I have been unsuccessful in trying to change the smtp port to either 465 (as Verizon recommends) or 587 (as others recommend). Following is my master.cf file:

smtp inet n - - - - smtpd

465 inet n - - - - smtpd

#smtp inet n - - - 1 postscreen
#smtpd pass - - - - - smtpd
#dnsblog unix - - - - 0 dnsblog
#tlsproxy unix - - - - 0 tlsproxy
#submission inet n - - - - smtpd
# -o syslog_name=postfix/submission
# -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#smtps inet n - - - - smtpd
# -o syslog_name=postfix/smtps
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authentica -o milter_macro_daemon_name=ORIGINATING
#628 inet n - - - - qmqpd
pickup unix n - - 60 1 pickup
cleanup unix n - - - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - - 1000? 1 tlsmgr
rewrite unix - - - - - trivial-rewrite
bounce unix - - - - 0 bounce
defer unix - - - - 0 bounce
trace unix - - - - 0 bounce
verify unix - - - - 1 verify
flush unix n - - 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - - - - smtp
relay unix - - - - - smtp
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - - - - showq
error unix - - - - - error
retry unix - - - - - error
discard unix - - - - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - - - - lmtp
anvil unix - - - - 1 anvil
scache unix - - - - 1 scache
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}

timothy

Posted 2016-01-06T21:13:31.533

Reputation: 1

Mail between servers is still transported over port 25, and like you say, is blocked by some ISPs. I personally have my mail server running on a VPS because of this issue :/ You could request that your ISP unblock the port. – Matt Clark – 2016-01-06T23:21:31.277

There are also services you can use which would circumvent this. See this.

– Matt Clark – 2016-01-06T23:22:17.697

Answers

0

master.cf only defines which services & ports your Postfix will listen on, i.e. which incoming connections to accept. It does not affect how outgoing mail is sent.

Now, while Postfix has quite a few options for its "smtp" transport, it doesn't actually let you change the SMTP port. But that's fine, because even if you did change the outgoing SMTP port to 587 or whatever, it wouldn't do any good – most receiving servers are not listening on that port anyway; your error messages would simply change to "Connection refused" (or perhaps "Message rejected; authentication needed"). The SMTP mail exchange (server-to-server) port is 25, end of story.


Your "recommendations" probably come from instructions about configuring the mail server to accept SMTP connections from a mail app such as Thunderbird or Outlook – indeed the SMTP client-to-server (mail submission) port is 587, and some older configurations still use 465 for this.

At first, port 25 was used for all mail, but later it was separated into 25 for server-server mail exchange and 587 for client-server mail submission. This allows the server to apply different rules to each – e.g. it's allowed to fix up certain problems in client-submitted mail, and ISPs can block port 25 while still allowing 587.

(Some mail apps used port 465 for "SMTPS" – SMTP with TLS (like HTTPS) – but it had downsides like not being usable for server-server communications. It was eventually replaced by STARTTLS over port 25 & 587. IANA has since reassigned port 465 to another protocol, and it shouldn't be used for mail anymore.)


So what to do in your case? There are a few general options.

First, if you're trying to turn your computer into a full mailserver for your own domain:

  • Preferred option: Ask your ISP to unblock SMTP connections. (Some ISPs do remove the blocks if you ask nicely and promise not to spam.)

  • Make Postfix use the ISP-provided "relay" server aka smarthost. (Only some ISPs offer this, though, and you'll still need to do something for incoming mail, too...)

  • Make all SMTP connections go through a VPN. (Ideally it should be a VPN through your own rented server somewhere – don't even think about the privacy-oriented "Hide my ass"-type VPNs, they already block port 25 the same way for all the same reasons.)

Or, if you just want mail to send mail from an existing account (e.g. Gmail or GMX):

  • Again, configure Postfix to use Gmail's or GMX's "relay" server – essentially make it work like a regular mail app, going through [smtp.gmail.com]:587, with your username & password.

    (There are quite a few "postfix gmail" tutorials out there, but you could also replace Postfix entirely with a relay-only tool like msmtp or esmtp, which were made for this purpose.)

  • Or install s-nail (previously known as heirloom-mailx) – a version of mail that knows how to use SMTP directly without going through the OS mail system. (That's how other mail apps work, anyway.) The command will still be mail.

    (If I remember correctly, GNU mailutils also has a mail command with SMTP support.)

user1686

Posted 2016-01-06T21:13:31.533

Reputation: 283 655