• Mint send email from command line

    From Graham J@nobody@nowhere.co.uk to alt.os.linux on Sat Jul 11 22:32:35 2026
    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.
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.os.linux on Sat Jul 11 17:47:37 2026
    From Newsgroup: alt.os.linux

    On Sat, 7/11/2026 5:32 PM, 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%

    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
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Gamgee@gamgee@palantirbbs.ddns.net.remove-d92-this to Graham J on Sat Jul 11 20:55:20 2026
    From Newsgroup: alt.os.linux

    To: Graham J
    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 use either 's-nail' or 'mailx', depending on what system/distro is
    being used. Both work well. You'd want to create a '.mailrc' file in
    your home directory.



    ... Gone crazy, be back later, please leave message.
    --- MultiMail/Linux v0.52
    --- Synchronet 3.22a-Linux NewsLink 1.2
    Palantir BBS - telnet://palantirbbs.ddns.net
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Sun Jul 12 09:14:29 2026
    From Newsgroup: alt.os.linux

    Paul wrote:
    [snip]

    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

    The digitalocean site repeatedly flashes its cookie acceptance dialog
    and is unuseable. This is with both Firefox and Chrome.

    Some more examples.

    https://devopswithamol.medium.com/mastering-email-from-the-linux-command-line-a-developers-guide-97c839f3404c

    I tried to install mailutils. 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:

    mail
    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. Is there something
    simpler that I can install on Mint?
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Sun Jul 12 13:29:12 2026
    From Newsgroup: alt.os.linux

    On 2026-07-12 10:14, Graham J wrote:
    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:

    mail
    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.

    Yes, you do. It is Linux.


    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?

    Don't install, use whatever your distribution uses. You have to ask in a mint forum or group.

    For example, in one script of mine, I use:

    echo -e "$NOTIFYTYPE\r\n\r\nUPS: $UPSNAME\r\nAlert type: $NOTIFYTYPE\r\n\r\n`upsc $UPSNAME`" | \
    mail -r username@MAILSERVER.net -s "NUT report Isengard ($NOTIFYTYPE)" \
    MYNAME@gmail.com


    But it works that simple because before using mail I configured postfix. mail is actually mailx. mailx can also be configured to work without an SMTP local server.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@ldo@nz.invalid to alt.os.linux on Sun Jul 12 21:23:45 2026
    From Newsgroup: alt.os.linux

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Lew Pitcher@lew.pitcher@digitalfreehold.ca to alt.os.linux on Sun Jul 12 22:15:42 2026
    From Newsgroup: alt.os.linux

    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)

    fastmail(1) is part of the elm(1) email client, and sendmail(1) is
    an SMTP server (which also can act as an email client, of sorts).

    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>

    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") (typically either qmail, postfix, or sendmail), which takes the configuration values you ascribe to server, security,
    smtp_user, and smtp_password. The various email MUAs ("Mail User Agents"), including fastmail, mailx, and sendmail (when used as an MUA) talk to the
    local MTA (or the one defined in their configuration files).

    The typical batch invocation of utilities like fastmail and mailx would look something like
    fastmail -s "My subject" - sombody@somewhere <<EOM
    this is the content of my email message
    EOM

    or
    /path/to/some/program | fastmail -s "My subject" - sombody@somewhere

    HTH
    --
    Lew Pitcher
    "In Skills We Trust"
    Not LLM output - I'm just like this.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From rbowman@bowman@montana.com to alt.os.linux on Sun Jul 12 23:42:12 2026
    From Newsgroup: alt.os.linux

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Mon Jul 13 02:58:53 2026
    From Newsgroup: alt.os.linux

    On 2026-07-12 23:23, Lawrence DrCOOliveiro wrote:
    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.

    This will confuse him a lot. It is in fact not related to his setup or problem.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Mon Jul 13 03:08:53 2026
    From Newsgroup: alt.os.linux

    On 2026-07-13 01:42, rbowman wrote:
    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.

    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.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From J.O. Aho@user@example.net to alt.os.linux on Mon Jul 13 08:14:28 2026
    From Newsgroup: alt.os.linux

    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


    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


    The configuration file can have more than one account, so you can add
    more than the default.

    How well this works, I can't say as I don't use msmtp, I have a full MTA
    on my machines, so they use the local SMTP server and then forwards it
    to an external server, so I can use mail, but that is far more to setup
    and a lot more complicated.
    --
    //Aho

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Mon Jul 13 10:48:45 2026
    From Newsgroup: alt.os.linux

    Lew Pitcher wrote:

    [snip]


    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")

    [snip]

    Thanks. That explains why I can't do the apparently very simple thing
    that I want.
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Mon Jul 13 10:51:03 2026
    From Newsgroup: alt.os.linux

    Carlos E. R. wrote:
    [snip]


    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.

    OK, thanks.

    Can anybody recommend a good Mint newsgroup where I might post my request?
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Mon Jul 13 10:59:40 2026
    From Newsgroup: alt.os.linux

    J.O. Aho wrote:
    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

    [snip]

    OK I see that having a separate configuration file may be useful in some circumstances. 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.
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Mon Jul 13 15:12:04 2026
    From Newsgroup: alt.os.linux

    On 2026-07-13 11:51, Graham J wrote:
    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?

    Well, there is alt.os.linux.mint. I don't use mint, so obviously I don't
    know how good it is. But it is a point to start.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Mon Jul 13 15:15:25 2026
    From Newsgroup: alt.os.linux

    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.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Paul@nospam@needed.invalid to alt.os.linux on Mon Jul 13 10:22:28 2026
    From Newsgroup: alt.os.linux

    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.

    Mozilla
    | \
    | \
    | + Debian ----------------------
    | | \ \
    | Ubuntu Devuan(X11) \
    \ / | \ \
    Linux-Mint Zorin Xubuntu Linux-Mint LMDE (escape hatch iff Canonical problem)
    Kubuntu
    UbStudio

    The packages in the master distribution, are running, but occasionally
    need the odd patch. The next level down can patch them.

    Linux Mint transfers a lot of materials, verbatim, from the tree above.

    Linux Mint makes value statements about some things. Like not embracing SNAP. This has meant some deals were struck with the maker of a software in
    order to get a distribution. If Ubuntu won't take a .deb from Debian,
    and insists on making its own SNAP package, then distros below Ubuntu
    are left without a .deb as an alternative. And then they have to go to Debian or to the supplier (above the tree) to have custom packages prepared.

    On the left hand side of the diagram, Clem does not seem to like reaching
    up straight to Debian. And that's because of the URLs used for updates
    and where your updates come from. Some of the fetches Linux Mint does,
    are to security.ubuntu.com kind of thing. I don't think, for the left
    hand side of the diagram, that Clem wants to complicate matters for
    users (figuring out what has failed at update time). When there was
    the big Ubuntu outage, the behavior was relatively simple (as these
    things go). All the mirror statuses went down at the same time.
    Again, value statements, careful control of materials.

    For something like administrator-mail functions, Linux Mint is most
    likely to use whatever Ubuntu has set up. Debian might have, say,
    three schemes and no "bias" at install times. Ubuntu, if they want,
    can pick a scheme. Then, Linux Mint inherits the scheme Ubuntu has selected (and honed to working state). Clem relies on Canonical for prep,
    because Clem doesn't have a big enough team to be patching 25000 packages. Clem, as a software dev, still writes custom software for the distro.
    He's not passively sitting in a chair and just drinking coffee.
    He's busy, and when a package issue comes up, he'll indicate
    that Ubuntu will fix the average, run-of-the-mill thing.

    The Linux Mint LMDE, is a project derived from Debian, which means
    the packages don't receive the Ubuntu polishing. But if the deal
    between Canonical and Clem breaks down for any reason, then Linux Mint
    might at some point, only make the LMDE one. Perhaps without Driver Manager. And Driver Manager is only as good as the chaos that feeds into it.
    If someone above Driver Manager messes around, ordinary users
    reach into Synaptic and fix it (I deleted 20 packages to do that).
    Which is not an ideal situation. That would be one of those days
    where I would do a backup of slash, before reaching for my tools.
    My screen was stuck at 1024x768, until I fixed that. Didn't take
    too long. Took as long for the backup, as the repair right after
    the backup. I delete pretty quickly, when I'm angry.

    If Synaptic isn't installed, you can

    sudo apt install synaptic

    and have a copy. There should be sufficient search there, to find
    a subset of materials for review.

    apt search mailx # Doing a package search (without elevation), from cmdline

    Paul
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From J.O. Aho@user@example.net to alt.os.linux on Mon Jul 13 17:31:21 2026
    From Newsgroup: alt.os.linux

    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


    But for me ideally I would like all the required parameters to be in my script, not scattered around the file system.

    There is the option of making a custom php script using PHPMailer or
    python script with smtplib and then you use your custom script for
    sending your mail, but sure it's kind of the same as you will have
    multiple files.

    https://www.mailersend.com/blog/php-send-emailhttps://realpython.com/python-send-email/
    --
    //Aho
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From John Hasler@john@sugarbit.com to alt.os.linux on Mon Jul 13 11:41:18 2026
    From Newsgroup: alt.os.linux

    Carlos E.R. writes:
    Well, in mailx you configure the "mail server" in the config file.

    You can specify everything on the command line.
    --
    John Hasler
    john@sugarbit.com
    Dancing Horse Hill
    Elmwood, WI USA
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From rbowman@bowman@montana.com to alt.os.linux on Mon Jul 13 17:38:03 2026
    From Newsgroup: alt.os.linux

    On Mon, 13 Jul 2026 10:51:03 +0100, Graham J wrote:

    Can anybody recommend a good Mint newsgroup where I might post my
    request?

    https://forums.linuxmint.com/
    https://www.reddit.com/r/linuxmint/


    There is alt.os.linux.mint that has some traffic. Usenet really isn't
    where it's at.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Mon Jul 13 20:03:07 2026
    From Newsgroup: alt.os.linux

    On 2026-07-13 16:22, Paul wrote:
    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.

    Ah, but I am not that familiar with it. Not in RAM. :-)

    Thanks for the summary :-)
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Tue Jul 14 08:48:20 2026
    From Newsgroup: alt.os.linux

    J.O. Aho wrote:
    [snip]

    OK I'm getting somewhere. Questions in-line ...

    sudo apt install msmtp

    This installs OK. It offered Apparmor which I declined.

    man msmtp shows the same text as https://manpages.org/msmtp - handy
    since I can have that open on another screen for reference.

    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

    Your example edited to show my details ...

    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

    The option --subject is rejected. I can't find any mechanism to include
    the subject field. It's not listed in the man pages. So my test line is:

    echo "Message" | msmtp -a default <recipient_email_address>

    This does nothing for about 3 minutes, then reports:

    msmtp: the server sent an empty reply
    msmtp: could not send mail (account default from /home/graham/.msmtprc)

    Option --P shows me all the configuration settings as I expect to see
    them. The last line is "reading recipients from the command line", then nothing happens for 3 minutes.

    Option -v or option -d or option --debug does not show any more
    information. The settings are shown, as they were for --P.

    Any ideas how I get it to tell me why it failed?

    Thanks ...
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Tue Jul 14 12:48:34 2026
    From Newsgroup: alt.os.linux

    On 2026-07-14 09:48, Graham J wrote:


    Any ideas how I get it to tell me why it failed?

    Thanks ...

    I searched for a while on google, did not find what I wanted, then I
    asked chatgpt.

    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.

    It also suggests using msmtp instead, but I am not familiar with it.
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From J.O. Aho@user@example.net to alt.os.linux on Tue Jul 14 15:03:32 2026
    From Newsgroup: alt.os.linux

    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.

    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.

    From the man page they had the following example

    env MAILRC=/dev/null from=scriptreply@domain smtp=host \
    smtp-auth-user=login smtp-auth-password=secret \
    smtp-auth=login mailx -n -s "subject" \
    -a attachment_file recipient@domain <content_file

    In this case they have a file with the body text, if you want to avoid
    that, then you use something like

    echo "the body of the mail" | env MAILRC=/dev/null
    from=scriptreply@domain smtp=host \
    smtp-auth-user=login smtp-auth-password=secret \
    smtp-auth=login mailx -n -s "subject" \
    -a attachment_file recipient@domain

    I hope that one work better for you, just install it with "sudo apt
    install mailx", at least I think that should work...
    --
    //Aho

    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Graham J@nobody@nowhere.co.uk to alt.os.linux on Tue Jul 14 18:42:36 2026
    From Newsgroup: alt.os.linux

    J.O. Aho wrote:
    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.

    [snip]

    What I want to achieve is exactly your example: "send things ... from
    scripts"

    So my recent questions stand:

    1. Nothing useful happens when I invoke msmtp:

    echo "Message" | msmtp -a default <recipient_email_address>

    msmtp: the server sent an empty reply
    msmtp: could not send mail (account default from /home/graham/.msmtprc)

    2. None of the debug commands (-v, -d, --debug) do anything more than
    the --P command.

    I did try mailx for which I had to install mailutils, and got nowhere as described earlier in this discussion.
    --
    Graham J
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Carlos E. R.@robin_listas@es.invalid to alt.os.linux on Tue Jul 14 19:59:44 2026
    From Newsgroup: alt.os.linux

    On 2026-07-14 19:42, Graham J wrote:
    I did try mailx for which I had to install mailutils, and got nowhere as described earlier in this discussion.

    touch /var/mail/graham
    --
    Cheers,
    Carlos E.R.
    ESEfc-Efc+, EUEfc-Efc|;
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Anssi Saari@anssi.saari@usenet.mail.kapsi.fi to alt.os.linux on Wed Jul 15 00:19:55 2026
    From Newsgroup: alt.os.linux

    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.
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Jasen Betts@usenet@revmaps.duckdns.org to alt.os.linux on Thu Jul 16 04:07:43 2026
    From Newsgroup: alt.os.linux

    On 2026-07-11, Graham J <nobody@nowhere.co.uk> 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% %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>


    s-nail swaks or msmtp

    I forget which advanced features each has or lacks, but I think they
    can all handle the above.

    Also you can use powershell if you really want to.

    Also nullmailer if a single system-wide config for the last 4 parameters is acceptable.
    --
    Jasen.
    Efc|Efca -i-+-#-#-# -u-|-C-#-u-+-u
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Jasen Betts@usenet@revmaps.duckdns.org to alt.os.linux on Thu Jul 16 04:21:26 2026
    From Newsgroup: alt.os.linux

    On 2026-07-13, J.O. Aho <user@example.net> wrote:
    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


    When using msmtp for a variable password I do "--password=echo '${pass/'/\"'\"}'"

    this puts some limitations on the chracaters allowed in the password,
    possible risk of shell injection etc...
    --
    Jasen.
    Efc|Efca -i-+-#-#-# -u-|-C-#-u-+-u
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Jasen Betts@usenet@revmaps.duckdns.org to alt.os.linux on Thu Jul 16 04:47:06 2026
    From Newsgroup: alt.os.linux

    On 2026-07-14, J.O. Aho <user@example.net> wrote:
    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).

    ??? I use it to send email from a script to an smtp server...

    from the script I use:

    mx=()
    mxn=0

    [ "$sender" ] || sender='<>'

    if [ "$HELO_HOST" ]
    then
    mx[$((mxn++))]="--domain=$HELO_HOST"
    fi

    [ "${HOST%:*}" ] && mx[$((mxn++))]="--host=${HOST%:*}"
    [ "${HOST#*:}" != "$HOST" ] && mx[$((mxn++))]="--port=${HOST#*:}"

    if (( AUTH ))
    then
    mx[$((mxn++))]="--user=$user"
    export pass
    mx[$((mxn++))]='--password=echo "${pass}"'
    [ "$authtype" ] || authtype=on
    fi
    if [ "$authtype" ]
    then
    mx[$((mxn++))]="--auth=${authtype#auth=}"
    fi

    if [ "$SMTPS" ]
    then
    mx[$((mxn++))]="--tls=on"
    else
    [ "$SSL" ] && mx[$((mxn++))]="--tls-starttls=on"
    fi
    [ "$SSL" = noverify ] || mx[$((mxn++))]="--tls-certcheck=off"
    [ "$SSL" = strict ] && mx[$((mxn++))]="--tls-certcheck=on"

    echo -n "$DATA" | msmtp "${mx[@]}" --from="$sender" $RECIPIENT


    here "$DATA" is the email content including all headers.
    note: --password wants a command that prints the password - I used echo "${pass}"

    I needed msmtp to test SCRAM-SHA1 auth mechnism.
    --
    Jasen.
    1 Efc|Efca -i-+-#-#-# -u-|-C-#-u-+-u
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From Jasen Betts@usenet@revmaps.duckdns.org to alt.os.linux on Thu Jul 16 05:06:12 2026
    From Newsgroup: alt.os.linux

    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
    --
    Jasen.
    Efc|Efca -i-+-#-#-# -u-|-C-#-u-+-u
    --- Synchronet 3.22a-Linux NewsLink 1.2
  • From vallor@vallor@vallor.earth to alt.os.linux on Fri Jul 17 00:34:24 2026
    From Newsgroup: alt.os.linux

    At Thu, 16 Jul 2026 05:06:12 -0000 (UTC), Jasen Betts <usenet@revmaps.duckdns.org> wrote:

    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

    I think BCP would be to set up postfix (so cron alerts will
    be delivered properly, also), and then use that.


    #!/bin/bash
    die() {
    sendmail -t <<@EOF
    From: sender@example.com
    To: recipient@example.com
    Subject: $1

    $1

    This could be bad.
    @EOF
    exit 1;
    }

    die "Oh no, there was an error!"
    #########

    Note that "sendmail -t" is a standard interface -- if postfix is
    set up properly, it will Do The Right Thing.

    However: if you're talking about mailing the output of cron jobs,
    you don't even need to do that -- cron does it automatically,
    and you can set the "MAILTO" variable in the crontab to designate
    a recipient.
    --
    -v ASUS TUF DASH F15 x86_64 Mem: 15.9G
    OS: Linux 7.0.0-14-generic D: Mint 22.3 DE: Xfce 4.18 (X11)
    NVIDIA GeForce RTX 3060 Mobile (6G) 610.43.02
    "Nothing is as inevitable as a mistake whose time has come"
    --- Synchronet 3.22a-Linux NewsLink 1.2