# 错误信息如下
msmtp: cannot log to /var/log/msmtp.log: cannot open: Permission denied

由于系统使用 apparmor 且msmtp安装后默认配置为:

[root@raspberrypi ~ 20:45:11]$cat /etc/apparmor.d/usr.bin.msmtp 
  ...
  owner @{HOME}/.msmtp*.log wk,
  /var/log/msmtp            wk,

  owner @{HOME}/**/*msmtprc        r,
  owner @{HOME}/.config/msmtp/*    r,
  owner @{HOME}/.cache/msmtp/*     r,
  owner @{HOME}/.cache/msmtp/*.log wk,
  ...

所以使用 /var/log/msmtp 作为 log 文件即可, 并设置权限为 644

Q.E.D.