Hi,
I would like to learn how to make use the mail
command to send mails to local accounts (well, just to myself would be enough). At the very minimum, I would like to run mail
every time I open a terminal window so that I’m notified for example if one of my user services failed to start (and change my unit files so that a mail is sent in case of failure, of course).
Now the problem is that OOTB it doesn’t seem to work on TW.
Initially I had a problem raised by postfix with myhostname not set.
I fixed that by simply running sudo config.postfix
and restarting the systemd postfix.service.
Not sure why I needed that, since the default value should be $(hostname -f) as per postfix’s documentation, and that command correctly yielded andromeda
on my machine, but whatever - what matters is that now config.postfix appended a bunch of variables to /etc/postfix/main.cf, and myhostname is one of them, and it’s now set to andromeda
, as a hard-coded value.
Now the error I was seeing when using mail
to send a message is gone:
echo "This is a test email" | mail -s "Test Email Subject" andrea
returns without errors.
And yet when I check for mail with mail
, I see “No mail for andrea”
If I check with mailq
, there are a bunch of these:
❯ mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
1161F70364 2456 Mon Jan 6 09:05:05 MAILER-DAEMON
(cannot update mailbox /var/mail/andrea for user andrea. unable to create lock file /var/mail/andrea.lock: File exists)
andrea@andromeda
18CE97180E 450 Mon Jan 6 09:27:23 andrea@andromeda
(cannot update mailbox /var/mail/andrea for user andrea. unable to create lock file /var/mail/andrea.lock: File exists)
andrea@andromeda
The lock file permissions are a bit suspicious:
ls -al /var/mail/andrea.lock
----------. 1 andrea andrea 0 Jan 6 09:25 /var/mail/andrea.lock
Maybe it’s a permission issue at the end of the day?
I wish this whole thing was setup to properly work OOTB, at least for sending messages to local accounts (or at least not to any local account, just to myself).
I’m also sharing my /etc/postfix/main.cf here:
https://paste.opensuse.org/pastes/df0039ccde93
Thanks!