Version 16 (modified by 10 months ago) ( diff ) | ,
---|
Sending Email
The 825gen2 can send emails.
The sendmail and msmtp commands are included in our Linux build.
Create the msmtp config file
nano ~/.msmtprc
Type the email account information such as:
defaults tls on account gmail auth on host smtp.gmail.com port 587 user [email protected] from [email protected] account default : gmail
Save the configuration file.
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 as a text file.
nano message.txt
Type the email such as:
From: [email protected] To: [email protected] Subject: Test email from 825 Test 825ARM Variscite 123456 abc
Send the email
msmtp -t < message.txt password for [email protected] 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
Add the password line with the previously obtained app specific password from Google.
defaults tls on account gmail auth on host smtp.gmail.com port 587 user [email protected] from [email protected] password ueut jrqv eapo eaid account default : gmail root@imx8mq-var-dart:~# msmtp -t < message.txt
The Email 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 into mime format.
Update message.txt to add MIME encoding
nano message.txt
From: [email protected] To: [email protected] 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
We may create or find a library to generate mime encoded emails from application code.
Attachments (2)
- google_app_password.png (42.8 KB ) - added by 10 months ago.
- 825test_email.png (25.6 KB ) - added by 10 months ago.
Download all attachments as: .zip