How to send myself mail via bash script? sendmail: executable not found (adjust *mta* variable); Currently no active mailbox

in my bash script i have used mail command to send mail to remote server:

$ ./script.sh
mail: Cannot start /usr/sbin/sendmail: executable not found (adjust *mta* variable)
/home/me/dead.letter 8/378
mail: ... message not sent

when i changed remote recipient e-mail address to my current username (it is enough for the purpose), then no sendmail error, but i was not notified about new mail :-S

$ mail
mail: /var/spool/mail/me: No such entry, file or directory
mail version v14.9.19.  Type `?' for help
(Currently no active mailbox)
No more mail.
mail: There are new messages in the error message ring (denoted by ERROR),
mail:   which can be managed with the `errors' command
ERROR# ? 

I had to get away using Ctrl+D shortcut :-/

How to proceed please to let it send mail to myself?

Did you see [SOLVED] Cannot start "/usr/bin/sendmail" / Newbie Corner / Arch Linux Forums? That would be a good place to start. :penguin:

They suggest installing mail and starting it. How i should do it on Manjaro?
I would think mail is basic thing that works out of the box on Linux like Manjaro+XFCE.

$ pacman -Qs mail
local/mailcap 2.1.49-1
Helper application and MIME type associations for file types

local/perl-mailtools 2.21-4
Various e-mail related modules

local/s-nail 14.9.19-2
Environment for sending and receiving mail

local/thunderbird 78.6.0-1
Standalone mail and news reader from mozilla.org

local/xfce4-mailwatch-plugin 1.3.0-1 (xfce4-goodies)
Multi-protocol, multi-mailbox mail watcher for the Xfce4 panel

$ systemctl|grep -i ail
…nothing related…

$ mail --help
mail (mail v14.9.19): send and receive Internet mail

You need a tool that can pick up the system mail and send it to the destination, depending on the destination s-nail might be enough. Do you want it to send to a real eMail address or just to a local user?

If simple, please kindly tell both cases @xabbu , if not, then local destination (mail -s subject – myusername) would be sufficing as i have mentioned. I remember on other PC, it always shown on command prompt when i got new mail. Not sure if it will be this case, i just need a custom notification displayed on some safe place so i do not miss it and the trigger will be my bash script. Btw. when i tried to add new mailbox to Thunderbird, it expect only user@domain.tld, so does not seem like local mailbox compatible.

It has been a very long time since I set up an MTA on Linux, but IIRC, postfix provides sendmail and it’s possible to send to user@localhost and user@another.domain. There may be some configuration to do for it to send to another.domain, but I believe it’s possible.

If you want to send it to a different smtp server, you can configure s-nail to do it.
https://wiki.archlinux.org/index.php/S-nail#Sending_mail_with_an_external_SMTP_server

Sometimes real Mailserver are a little bit picky, you might need to use Msmtp or a similar tool.
https://wiki.archlinux.org/index.php/Msmtp

If you want to just send mail locally, you need a MTA. There is no way around it, but a bash script can be a MTA. A simple to configure real MTA is postfix. It can do a lot, but it can also deliver mail locally.

There is also femtomail. It is in the AUR, but you need to edit the PKGBUILD to add your username and change the mailbox path. It will deliver all mail to a single user. It is special, but it might work for you.

https://git.lekensteyn.nl/femtomail/tree/README.md

1 Like

You should install postfix from the repo.

These are unrelated update problems with other packages. If you can’t fix them, you might want to create a new topic with this problem.

1 Like

after installing postfix, it continue like before:

$ mail
mail: /var/spool/mail/me: No such entry, file or directory
mail version v14.9.20.  Type `?' for help
(Currently no active mailbox)
No more mail.
mail: There are new messages in the error message ring (denoted by ERROR),
mail:   which can be managed with the `errors' command
ERROR# ? ^D

$ touch /var/spool/mail/me

$ mail
mail version v14.9.20.  Type `?' for help
/var/spool/mail/me: 0 messages
No more mail.
? q

$ echo message|mail -s subject me
postdrop: warning: unable to look up public/pickup: No such file or directory

Ok, again useless message that don’t tell you what to do when you are basic Linux user who just want to read mail. So after research that could be saved, i found command:
$ sudo mkfifo /var/spool/postfix/public/pickup

not sure if needed, necessary:
$ systemctl start postfix
$ systemctl enable postfix

$ echo message|mail -s subject me
$ mail
mail version v14.9.20. Type `?’ for help
/var/spool/mail/me: 0 messages
No more mail.
?

$ mailq
shows numerous queued mails, among it:
me@me.localdomain
(alias database unavailable)

$ journalctl
postfix/local[105120]: error: open database /etc/postfix/aliases.db: No such file or directory
postfix/local[105117]: warning: hash:/etc/postfix/aliases: lookup of ‘me’ failed
postfix/local[105117]: warning: hash:/etc/postfix/aliases is unavailable. open database /etc/postfix/aliases.db: No such file

so still nothing

After another research: $ sudo newaliases
echo body|mail -s subject me
it finally delivered mail. I hate this, why i had to waste time and time of the people here, instead it work out of the box.

A basic Linux user opens a Webbrowser, types in the URL of his favorite Mail service, logs in and starts reading and sending mail.

You don’t want to read mail, you want to send a Mail to your local user account. This is something totally different. A basic Linux user doesn’t want this and will not be able to do this.

You need to configure postfix (and start the service). It will not work out of the box. Start reading the documentation.

1 Like

Thanks @xabbu for reply.

Next is just my whining, so ignore it if not prepared:

Maybe developers does not have time to maintain more user friendly installation. So they rather let users waste their time, i understand that. It is similar like with the pamac issue i have described a few posts earlier in this topic. It not told me what to do nor invited to do it for me. Same with pacman -Syu a few days earlier

or developers brain is unable to comprehend that not everyone is able to become superuser who have all the info in the mind and that @xabbu and similar users time can be saved responding to constantly repeated questions.

My picture would be i type mail command and it tell me:
mail is NOT configured to send mail to yours defined address, do you want to setup that?
Please select MTA to install:
MTA1 (details)
MTA2 (details)
Installation complete, do you want to:

  • setup accounts for local users
  • create database
  • enable the mail service?
    y

Same problem here. Strange. As workaround I created a symbolic link:

/usr/sbin/sendmail → /usr/bin/sendmail

Solved my similar problem today. I noticed the problem first after having restored from my rsync-backup (update broke my system). /usr/sbin is an empty dir in the backup. But according to Frequently asked questions - ArchWiki /usr/sbin should be a symbolic link to /usr/bin.

Is your /usr/sbin an empty directory, too?

So I deleted the directory /usr/sbin and created a symbolic link:

lrwxrwxrwx 1 root root 8 1. Feb 20:03 sbin → /usr/bin

no, in my case, i already had the symbolic link of the /usr/sbin:

$ stat /usr/sbin /usr/sbin/sendmail|grep -E "File|Size"
  File: /usr/sbin -> bin
  Size: 3         	Blocks: 0          IO Block: 4096   symbolic link
  File: /usr/sbin/sendmail
  Size: 30624     	Blocks: 64         IO Block: 4096   regular file

2 posts were split to a new topic: Configuring mta

necrobumped