1

I'm a beginner in linux and Raspberry Pi but I have some experiences with files systems and embedded systems in general.

I would like to achieve a read-only file system with Raspbian (Buster) and from there I would like to send some e-mails. First of all, I want to start sending e-mails via bash.

I'm using a Mac terminal to connect via ssh to my Raspberry 4 Model B. I followed this tutorial, to achieve a read only file system. This seems to work and I can switch between a ro and a rw system.

To send e-mails, I would like to use msmtp and iCloud. Therefore, I followed a post in this forum. I can't refer to the exact post, so I will show the steps here.

Install package

sudo apt-get install msmtp msmtp-mta

For gmail accounts, these are the specific elements you should put into /etc/msmtprc

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes the access rights
logfile        ~/.msmtp.log

# Gmail specifics
account        gmail
host           smtp.gmail.com
port           587

from          root@raspi-buster
user           your-gmail-accountname@gmail.com
password       your-gmail-account-password

# Default
account default : gmail

I changed the Gmail specific settings to iCloud specific settings

# Generics
defaults
auth           on
tls            on
# following is different from ssmtp:
tls_trust_file /etc/ssl/certs/ca-certificates.crt
# user specific log location, otherwise use /var/log/msmtp.log, however, 
# this will create an access violation if you are user pi, and have not changes$
logfile        ~/.msmtp.log

# Gmail specifics
account        icloud
host           smtp.mail.me.com
port           587

from          root@raspi-buster
user           myName@icloud.com
password       MyPassword

# Default
account default : icloud

Now test it!

echo 'your message' | msmtp destination-email-address@icloud.com

msmtp: cannot create temporary file: Permission denied

I get this result, even I set the file system to rw. Is it possible to map the temporary file to the RAM? It would be great, if anyone could explain me the issue in detail and give me an advise how to go on :)

1
  • Your question is about to send emails, but where is the problem with Raspberry Pi? You may consider to ask at unix.stackexchange.com to get quicker better solutions. – Ingo Apr 12 '20 at 18:03
1

I think your problems is specific file permission rights on a directory that the mail program is trying to use to create a temporary file rather than the read/write permissions on a mounted filesystem.

Has the logfile ~/.msmtp.log been created in your home directory. Take a look inside it to see if there is a helpful error message about creating a file/directory and then go and fix the permissions.

6
  • If I type in: pi@raspberrypi(ro):/$ cat ~/.msmtp.log I get this error message cat: /home/pi/.msmtp.log: No such file or directory – PascalS Apr 12 '20 at 14:29
  • OK what about the contents of /var/log/msmtp.log? – mhaselup Apr 12 '20 at 14:45
  • pi@raspberrypi(rw):/$ cat /var/log/msmtp.log results in cat: /var/log/msmtp.log: No such file or directory – PascalS Apr 12 '20 at 14:48
  • The issue seems to be related to write permissions to the /etc folder. After using chmod it worked :) – PascalS Apr 12 '20 at 19:03
  • That's good. It still begs the question that you have specified a local .msmtp.log file in your config file which appears to have been disregarded in favour of the default /etc/msmtp.log I wonder if other specified config values have been ignored. – mhaselup Apr 12 '20 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.