Score:1

msmtp logging doesn't work in /var/log/mail/[logfile].log

cn flag

Good day

I'm using msmtp to send mails. I have different accounts that log to different logfiles. Unfortunately whenever it tries to log the following error appears:

send-mail: cannot log to /var/log/mail/[logfile].log: cannot open: Permission denied

I tried the following:

  • change owner/group of the file
  • tried 777 on the logfiles
  • edited the file as the user running the command (which worked)
  • disabled apparmor

Nothing has worked so far. I've run out of ideas... what am I doing wrong?

Thanks all for your help!

andrew.46 avatar
in flag
Classically you would set the location and name of the logfile in ~/.msmtprc, in a location that you have write access to and make sure the whole ~/.msmtprc file has the appropriate permission: `chmod 600 ~/.msmtprc`. Do you really need the log file away from $HOME?
silbro avatar
cn flag
Thank you for your answer. Ideally I would like to have seperate logfiles because of the system we have set up with different clients. I know that the rights are ok, especially since I also tried 777.
Score:0
cn flag

So the problem was still the apparmor. I didn't restart the server and so it didn't work as expected. I followed the instructions found here and excluded msmtp from apparmor. This solved the problem.

https://linuxconfig.org/how-to-disable-apparmor-on-ubuntu-20-04-focal-fossa-linux

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.