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%
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>
Thanks.
Graham J wrote to alt.os.linux <=-
From Newsgroup: alt.os.linux
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>
Thanks.
I tried this as a search
linux administrator command line email
And this is an intro. of that sort of thing.
https://www.digitalocean.com/community/tutorials/send-email-linux-command-line
Some more examples.
https://devopswithamol.medium.com/mastering-email-from-the-linux-command-line-a-developers-guide-97c839f3404c
Paul wrote:
[snip]
I tried this as a search
-a-a-a-a linux administrator command line email
And this is an intro. of that sort of thing.
-a-a-a https://www.digitalocean.com/community/tutorials/send-email-linux- >> command-line
The digitalocean site repeatedly flashes its cookie acceptance dialog
and is unuseable.-a This is with both Firefox and Chrome.
Some more examples.
-a-a-a https://devopswithamol.medium.com/mastering-email-from-the-linux-
command-line-a-developers-guide-97c839f3404c
I tried to install mailutils.-a It failed to tell me that I had to use
the <tab> key to navigate the configuration (rather than up/down or
simply <enter> but having discovered the <tab> key was useful the configuration appeared to complete OK.
I can invoke it, with either:
or
mail.mailutils
and in both cases I see:
Cannot open mailbox /var/mail/graham: no such file or directory.
... well, obviously, I don't want a mailbox.
Man mail is voluminous but doesn't give any useful examples.
I suspect it's too sophisticated for my needs.-a Is there something
simpler that I can install on Mint?
Cannot open mailbox /var/mail/graham: no such file or directory.
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 Sat, 11 Jul 2026 22:32:35 +0100, 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 use fastmail(1) or mailx(1), or even sendmail(1)
On Sun, 12 Jul 2026 09:14:29 +0100, Graham J wrote:
Cannot open mailbox /var/mail/graham: no such file or directory.
Your user mailbox setup can be configured in various ways. For
example, I use maildir, which means per-user mail is kept in the ~-2user-+/.maildir directory.
You donrCOt really want different tools having different, conflicting settings for such an important collection of data. This is one reason
why I set up an IMAP server, and have my email client connect to that,
rather than trying to access my user mailbox directly.
On Sun, 12 Jul 2026 22:15:42 -0000 (UTC), Lew Pitcher wrote:
On Sat, 11 Jul 2026 22:32:35 +0100, 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 use fastmail(1) or mailx(1), or even sendmail(1)
Sendmail has one of O'Reily's thickest books dedicated to it. It can do anything if properly configured but generally does nothing that you really want to do.
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: | 74 |
| Nodes: | 6 (1 / 5) |
| Uptime: | 51:10:47 |
| Calls: | 1,101 |
| Calls today: | 1 |
| Files: | 1,339 |
| Messages: | 276,012 |