1

Topic: Error sending mail via (Neo)mutt/msmtp

================ Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7 MARIADB edition.
- Linux/BSD distribution name and version: Ubuntu 16.04.5 LTS
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hello

I've been setting up my mail server and have had success sending mail via roundcube, and using thunderbird and Android Gmail as clients. Both detect my servers certificates and authticate using starttls.

However, on my desktop I use neomutt to send/receive email and I am finding that I cannot send mail using either neomutt's built in smtp support or via msmtp.

For msmtp, the errors are as follows:

msmtp: envelope from address myuser@otherdomain.tld not accepted by the server                                  
msmtp: server message: 530 5.7.0 Must issue a STARTTLS command first
msmtp: could not send mail (account personal from /home/user/.msmtprc)

My conf file for msmtp is as follows:

protocol smtp
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
rls_certcheck on
tls_starttls on
 
.
.
.
 
# iRedMail Account
account personal
from username@domain.tld
user username
passwordeval "gpg --quiet --for-your-eyes-only --no-tty --decrypt ~/.mail/.username| awk '{print $4}'"
host smtp.domain.tld
port 587 

As for Neomutt, It tries to authenticate using (PLAIN) but then errors out with

SASL authentication failed

My mutt conf is as follows:

# Security Settings
set ssl_starttls=yes
set ssl_force_tls=yes

.
.
.

# Personal Settings
set from= "username@domain.tld"
set realname= "Real Name"

# Email Auth
source "gpg -dq $HOME/.mail/.username |"
set smtp_url = "smtp://username@domain.tld@smtp.domain.tld:587/"
set ssl_starttls=yes
set ssl_force_tls=yes
set smtp_pass =$my_pass
set imap_user = "username@domain.tld"
set imap_pass =$my_pass

.
.
.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Error sending mail via (Neo)mutt/msmtp

StephGreg wrote:

msmtp: server message: 530 5.7.0 Must issue a STARTTLS command first

This means your MUA didn't send STARTTLS command during SMTP session, which means TLS is not established. You may need to check your MUA setting.

3

Re: Error sending mail via (Neo)mutt/msmtp

Hello again.

When you say I need to check my MUA settings, what do you mean by that? My google-fu might be failing me here, but I can only find https://docs.iredmail.org/#mua. Do I need to enable the deprecated imaps functionality?

4

Re: Error sending mail via (Neo)mutt/msmtp

That log means your msmtp didn't actually send STARTTLS command to establish secure connection, this is a client-side issue (msmtp), not server-side issue.

So you must figure out a way to make sure your MUA (msmtp, Outlook, Thunderbird, mutt, etc) to actually establish secure connection.

5 (edited by StephGreg 2018-01-23 17:51:58)

Re: Error sending mail via (Neo)mutt/msmtp

Looks like my conf was bad. TO ALL FUTURE READERS, if your settings don't seem to be working, check your global defaults. I had them under

account default

which is wrong. The header for defaults is just

defaults
protolcol smtp
tls on ...

But now I have another problem. Even after I set up my config right, msmtp complains like so:

msmtp: authentication failed (method PLAIN)
msmtp: server message: 535 5.7.8 Error: authentication failed:
msmtp: could not send mail (account test from /home/user/.msmtprc)

I have no idea how this is happening, since using msmtp and starttls with gmail works fine.

Here's the excerpt from my maillog

Jan 23 09:31:56 mail postfix/submission/smtpd[4401]: connect from MY IP[MY IP]
Jan 23 09:31:57 mail postfix/submission/smtpd[4401]: Anonymous TLS connection established from MY IP[MY IP]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)
Jan 23 09:32:00 mail postfix/submission/smtpd[4401]: warning: MY IP[MY IP]: SASL PLAIN authentication failed:
Jan 23 09:32:00 mail postfix/submission/smtpd[4401]: lost connection after AUTH from MY IP[MY IP]
Jan 23 09:32:00 mail postfix/submission/smtpd[4401]: disconnect from MY IP[MY IP] ehlo=2 starttls=1 auth=0/1 commands=3/4

EDIT:

Looks like I goofed up again. The method I use to retrieve passwords had an extra character in its output. I tried it with a different user with a simpler password and it worked fine. Thanks ZhangHuangbin for your help anyway. I guess it pays to RTFM