marlam / msmtp

SMTP client with sendmail compatible interface
https://marlam.de/msmtp
GNU General Public License v3.0
176 stars 36 forks source link

Improved Documentation Request: Configuration File Requirement: Default Account #150

Closed NetScr1be closed 6 months ago

NetScr1be commented 6 months ago

I just spent a few hours chasing my tail learning there is a hidden requirement in the msmtprc file.

If we set up a configuration file like a number of sources say (e.g. this one);

auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

account default
host smtp.gmail.com
port 587
auth on
from your_mail@gmail.com
user your_mail@gmail.com
password "Generate a app password and pass it here for Auth, dont use your mail password directly" 

msmtp complains;

loaded system configuration file /etc/msmtprc
loaded user configuration file /home/<user>/.msmtprc
falling back to default account
msmtp: account default from /home/<user>/.msmtprc: host not set

What seems to be happening is when msmtp sees configuration parameters ***and there is no default account set***, it sets one and configures its environment but the default account it sets is missing parameters (host for one) and nothing works.

Even if a default account is expressly defined via;

#Set a default account
account default : google

msmtp just complains the default was already set.

Apparently the configuration file ***has to start*** with an account definition AND  the default account expressly defined;

account google
host smtp.gmail.com
port 587
auth on
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt

from user@email.com
user user@email.com
password <Google App Password>

logfile ~/.msmtp.log

#Set a default account
account default : google

I don't know if the configuration file interpretation method changed over time but it took a bunch of trial and error to figure this out.

Making this explicit in the documentation would save people some grief and make msmtp developers way more popular without having to put any effort into actually having social skills.

NetScr1be commented 6 months ago

BTW, even the Debian wiki seems to have it wrong.

I tried using the defaults keyword at the top of the file to no effect.

https://wiki.debian.org/msmtp

marlam commented 6 months ago

Pretty much every example of msmtp configuration, including the once in the Debian wiki, starts with either an account definition or a defaults section, as it should. From the documentation: "Commands are organized in accounts. Each account starts with the account command and defines the settings for one SMTP account."

Making this explicit in the documentation would save people some grief and make msmtp developers way more popular without having to put any effort into actually having social skills.

Not to add to your grumpiness, but: If you look to medium.com for advice on software configuration, well, you get what you asked for.