Tuesday, May 12, 2026

msmtp instead of mail

Noticed only today that for some scripts on our internal server, the mail command was commented out and replaced by msmtp like 

#mail -s "Automatic Encoded file Statistics for : date" -t $MAIL_COPY $MAIL_DESTINATION < $MAIL_FILE 

{ echo "To: $MAIL_DESTINATION"; echo "Cc: $MAIL_COPY"; echo "Subject: Automatic Encoded file Statistics: $(date)"; echo; cat "$MAIL_FILE"; } | /usr/bin/msmtp -t

ChatGPT explains,

Yes, on many modern Linux systems, using msmtp directly is now preferred over the traditional mail command, especially for scripts and automated systems.

The reason is that the mail command historically depended on a local Mail Transfer Agent (MTA) such as:

Sendmail
Postfix
Exim

Many newer minimal/server/container installations no longer install or configure a full local MTA.

This was mentioned in this previous post, which mentions a replacement of ssmtp with msmtp. 

No comments:

Post a Comment