Mail/postfix - please help me set them up for local message sending

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!

@andrea.ippo:

OK, Leap 15.6 but, AFAIK the permissions haven’t been changed for newer Kernel versions –

 > ls -ald /var/mail
lrwxrwxrwx 1 root root 10 15. Mär 2022  /var/mail -> spool/mail/
 > 
 > ls -ald /var/spool
drwxr-xr-x 13 root root 4096 15. Mär 2022  /var/spool
 > ls -ald /var/spool/mail
drwxrwxrwt 2 root root 4096  3. Okt 13:52 /var/spool/mail
 >  
 > rpm --query --whatprovides /var/mail
postfix-3.8.4-150600.3.3.1.x86_64
filesystem-15.0-11.8.1.x86_64
 > rpm --query --whatprovides /var/spool
filesystem-15.0-11.8.1.x86_64
 > rpm --query --whatprovides /var/spool/mail
postfix-3.8.4-150600.3.3.1.x86_64
filesystem-15.0-11.8.1.x86_64
 >

Please notice the “T” bit set on the “mail” directory.

I suggest that, you forcibly re-install at least the “filesystem” package –

# zypper install --force filesystem

Hi, thanks for chiming in :slight_smile:

Here is the current output for those commands:

    ~                                                                                                 ✘ INT
❯ ls -ald /var/mail
lrwxrwxrwx. 1 root root 10 Dec  5 20:05 /var/mail -> spool/mail

    ~                                                                                                      
❯ ls -ald /var/spool     
drwxr-xr-x. 1 root root 94 Jan  2 13:45 /var/spool

    ~                                                                                                      
❯ ls -ald /var/spool/mail
drwxrwxrwt. 1 root root 40 Jan  6 15:36 /var/spool/mail

    ~                                                                                                      
❯ rpm --query --whatprovides /var/mail
postfix-3.9.1-1.1.x86_64

    ~                                                                                                      
❯ rpm --query --whatprovides /var/spool     
filesystem-84.87-16.1.x86_64

    ~                                                                                                      
❯ rpm --query --whatprovides /var/spool/mail
postfix-3.9.1-1.1.x86_64

I’ll try reinstalling the filesystem package and see what happens, thanks