Version 10 (modified by 9 months ago) ( diff ) | ,
---|
Sending Email
The 825gen2 can send emails.
The sendmail and msmtp commands are included in our Yocto Linux build.
cd /home/root Create the msmtp config file nano ~/.msmtprc defaults tls on account gmail auth on host smtp.gmail.com port 587 user wilsonwareapps@gmail.com from wilsonwareapps@gmail.com account default : gmail
Google no longer allows applications to use regular Google login password. To send email using a Google account create an app specific password in the google web portal.
Keep a record of the generated password
ueut jrqv eapo eaid
Create an email
nano message.txt From: wilsonwareapps@gmail.com To: don@wilsonware.com Subject: Test email from 825 Test 825ARM Variscite 123456 abc
Send the email
msmtp -t < message.txt password for wilsonwareapps@gmail.com at smtp.gmail.com:
Enter the app password. Email was sent successfully.
How to store password to not require password entry every time email is sent?
Password can be added to config file such as:
nano ~/.msmtprc defaults tls on account gmail auth on host smtp.gmail.com port 587 user wilsonwareapps@gmail.com from wilsonwareapps@gmail.com password ueut jrqv eapo eaid account default : gmail root@imx8mq-var-dart:~# msmtp -t < message.txt
E-mail sent successfully with no prompt for password
This could be done from app code using a system call.
How to send file attachments?
msmtp does not have support for file attachments directly. The message must be encoded in mime format.
Update message.txt to add MIME encoding
nano message.txt From: wilsonwareapps@gmail.com To: dwilson@cardet.com Subject: Test email from 825 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MyBoundaryString" --MyBoundaryString Content-Type: text/plain Content-Transfer-Encoding: 7bit This is a message. --MyBoundaryString Content-Type: text/plain; file="file123.txt" Content-Disposition: attachment; filename="file123.txt" Content-Transfer-Encoding: base64
Create attachment file
nano attachment.txt This is an attachment 123456 abcdefg
Use base64 to convert the attachment to base64 encoding:
base64 attachment.txt > /tmp/attachment
Now pipe both files to the msmtp command
cat message.txt /tmp/attachment | msmtp -t
This successfully sends email with attachment
Attachments (2)
- google_app_password.png (42.8 KB ) - added by 9 months ago.
- 825test_email.png (25.6 KB ) - added by 9 months ago.
Download all attachments as: .zip