Can anybody suggest a simple utility for sending emails from the command line, which I could incorporate in a shell script, please?
I'm trying to replicate what I use in Windows, which looks like this:
mailsend1.19 %from%-a %to%-a %subject%-a %message%-a %server%-a %security% %user%-a %password%
There's nothing that I know of that would act as a drop in replacement
for your mailsend1.19 Windows command. Email, on most Linux systems, depends on a local MTA ("Mail Transfer Agent")
mailx can do what he wants, send mail from a script. It can use the
system MTA which could be sendmail or postfix or other; but this is not really needed, because mailx can be configured to talk instead to his
ISP MTA, remotely.
Unix or Linux mail clients, like "mail" or "mailx" assume that there is
a system mailbox folder. This has to exist, even if not used, and is typically "/var/mail/LOCALUSERNAME". A file. In this case, zero bytes,
so just do
touch /var/mail/graham
To tell more, we need someone that knows how mint is setup by default,
and go from there. Not "install this install that", without knowing what mint already installs and assumes.
Like, mint uses or not uses /var/mail/graham file.
We need to know what is the mint way.
On 11/07/2026 23.32, Graham J wrote:
Can anybody suggest a simple utility for sending emails from the
command line, which I could incorporate in a shell script, please?
I'm trying to replicate what I use in Windows, which looks like this:
mailsend1.19 %from%-a %to%-a %subject%-a %message%-a %server%-a %security% >> %user%-a %password%
sudo apt install msmtp
as the user as the script will be run edit (may not exist) the file ~/.msmtprc so that it looks like:
defaults
auth on
tls off
account default
host your.mailserver.com
port 465
user your_username
password your_password
from your_email@example.com
Carlos E. R. wrote:
[snip]
Like, mint uses or not uses /var/mail/graham file.
We need to know what is the mint way.
OK, thanks.
Can anybody recommend a good Mint newsgroup where I might post my request?
J.O. Aho wrote:
On 11/07/2026 23.32, Graham J wrote:
[snip]
OK I see that having a separate configuration file may be useful in some circumstances.-a I will try it later today.
But for me ideally I would like all the required parameters to be in my script, not scattered around the file system.
On 2026-07-13 11:59, Graham J wrote:
J.O. Aho wrote:
On 11/07/2026 23.32, Graham J wrote:
[snip]
OK I see that having a separate configuration file may be useful in some circumstances.-a I will try it later today.
But for me ideally I would like all the required parameters to be in my script, not scattered around the file system.
Well, in mailx you configure the "mail server" in the config file. Where is the MTA (aka smtp server),
the login, the password... that's the minimum. Then on the command line you give parameters as
the address, the subject, the content...
It is very typical.
OK I see that having a separate configuration file may be useful in some circumstances.-a I will try it later today.
But for me ideally I would like all the required parameters to be in my script, not scattered around the file system.
Well, in mailx you configure the "mail server" in the config file.
Can anybody recommend a good Mint newsgroup where I might post my
request?
On Mon, 7/13/2026 9:15 AM, Carlos E. R. wrote:
On 2026-07-13 11:59, Graham J wrote:
J.O. Aho wrote:
On 11/07/2026 23.32, Graham J wrote:
[snip]
OK I see that having a separate configuration file may be useful in some circumstances.-a I will try it later today.
But for me ideally I would like all the required parameters to be in my script, not scattered around the file system.
Well, in mailx you configure the "mail server" in the config file. Where is the MTA (aka smtp server),
the login, the password... that's the minimum. Then on the command line you give parameters as
the address, the subject, the content...
It is very typical.
For Graham, you could explain some of the hierarchy.
sudo apt install msmtp
as the user as the script will be run edit (may not exist) the file ~/.msmtprc so that it looks like:
defaults
auth on
tls off
account default
host your.mailserver.com
port 465
user your_username
password your_password
from your_email@example.com
then run the following command:
chmod 600 ~/.msmtprc
then use the following in your script (it's a one liner):
echo "your message body" | msmtp -a default --subject="what your subject should be" who.to.spam@exmaple.net
Any ideas how I get it to tell me why it failed?
Thanks ...
J.O. Aho wrote:
echo "your message body" | msmtp -a default --subject="what your
subject should be" who.to.spam@exmaple.net
The option --subject is rejected.-a I can't find any mechanism to include the subject field. It's not listed in the man pages.-a So my test line is:
The recipe is (using mailx from s-nail/Heirloom):
echo "Hello" | mailx \
-S smtp=smtp.example.com:587 \
-S smtp-use-starttls \
-S smtp-auth=login \
-S smtp-auth-user=myuser \
-S smtp-auth-password=mypassword \
-r me@example.com \
-s "Test" \
recipient@example.com
or configure these settings in ~/.mailrc and keep your script simple.
On 14/07/2026 09.48, Graham J wrote:
J.O. Aho wrote:
echo "your message body" | msmtp -a default --subject="what your
subject should be" who.to.spam@exmaple.net
The option --subject is rejected.-a I can't find any mechanism to
include the subject field. It's not listed in the man pages.-a So my
test line is:
This is my fault, trusted an hallucinating LLM too much and first now
took the time to read the full man page, msmtp will not work as we
thought, it works like a sendmail replacement that makes it easy to
relay mail to a real mail server, so you can send things with simple
mail clients or from system scripts (for example failed cron job notifications).
Go with the mailx instead, I hope it gives you all the options you need.
I did try mailx for which I had to install mailutils, and got nowhere as described earlier in this discussion.
Can anybody suggest a simple utility for sending emails from the
command line, which I could incorporate in a shell script, please?
Can anybody suggest a simple utility for sending emails from the command line, which I could incorporate in a shell script, please?
I'm trying to replicate what I use in Windows, which looks like this:
mailsend1.19 %from% %to% %subject% %message% %server% %security%
%user% %password%
So I need to specify details of the form:
from=me@mydomain.com
to=you@yourdomain.com
subject="subject text string"
message="message text string"
server=smtpserver@mydomain.com
security= ssl port=465 -auth
smtp_user=me@mydomain.com
smtp_password=<mypassword>
On 13/07/2026 11.59, Graham J wrote:
OK I see that having a separate configuration file may be useful in some
circumstances.-a I will try it later today.
For using the same mail credentials over and over again, it's simple,
but suing random new ones, will make things a bit more difficult.
When I hastily looked at the man page (man msmtp), seems you can do all
the things from command line too, so you should be able to ignore the configuration file. Drop the -a and use --host --port --auth --user,
sadly the password you can't use from command line, it will most likely
be handled by a password manager from gnome project.
https://manpages.org/msmtp
On 14/07/2026 09.48, Graham J wrote:
J.O. Aho wrote:
echo "your message body" | msmtp -a default --subject="what your
subject should be" who.to.spam@exmaple.net
The option --subject is rejected.-a I can't find any mechanism to include >> the subject field. It's not listed in the man pages.-a So my test line is:
This is my fault, trusted an hallucinating LLM too much and first now
took the time to read the full man page, msmtp will not work as we
thought, it works like a sendmail replacement that makes it easy to
relay mail to a real mail server, so you can send things with simple
mail clients or from system scripts (for example failed cron job notifications).
Graham J <nobody@nowhere.co.uk> writes:
Can anybody suggest a simple utility for sending emails from the
command line, which I could incorporate in a shell script, please?
Since no one has mentioned it so far, the text based email client "mutt"
has command line options to send mail. I haven't done that in years but
seems it's still supported. I don't know if it's packaged in Mint
though. There's a variant called neomutt as well.
On 2026-07-14, Anssi Saari <anssi.saari@usenet.mail.kapsi.fi> wrote:
Graham J <nobody@nowhere.co.uk> writes:
Can anybody suggest a simple utility for sending emails from the
command line, which I could incorporate in a shell script, please?
Since no one has mentioned it so far, the text based email client "mutt" has command line options to send mail. I haven't done that in years but seems it's still supported. I don't know if it's packaged in Mint
though. There's a variant called neomutt as well.
There are many command-line email senders, howerver many do not accept the smtp server name on the command-line, with mutt I guess you could use
'-e' to provide config file settings on the command-line
mutt -F /dev/null -e 'set smtp_url="smtps://user:pass@host:port"' -e 'set from="you@gmail.com"'
details in the muttrc manpage
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 53:43:37 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,448 |