Updated 4/4/2025
You cannot use simple command line clients to send email to Gmail or Yahoo domains because of the extra authentication that is required [1].
One of the features of Proton Mail is that you can send emails through their SMTP servers without loggin in through a web browser. This feature is only available for business accounts.
Proton mail refers to this as SMTP Submission
Their most economical plan for doing this is "Mail Professional" ($10/month).
The "Simple" Mail Transfer Protocol (SMTP) is not that simple. To reduce the complexity go between programs were developed such as ssmtp, msmtp and swaks.
Unforunately, With these programs, comes limiations. For example ssmpt only support two authenification methods: LOGIN and CRAM-MD5.
Proton's smtp-submission requires that the authenification method be PLAIN.
Furthermore, ssmtp has not been maintained since 2019. Debian suggest using msmtp as its replacement. However, I found it to be more complex than swaks.
However, because of spammer, the authenification for logging into one of these servers via SMPT has become complex.
swaks stands for: swiss army knife for smtp
The folowing is from reference [1] below:
swaks \ --from sender@example.com \ --to recipient@example.com \ --server send.ahasend.com \ --port 587 \ --auth plain \ --tls \ --auth-user 'YOUR_SMTP_USERNAME' \ --auth-password 'YOUR_SMTP_PASSWORD' \ --header 'Subject: Test email' \ --body "This is a test email."
Substituing my values into this example:
swaks \ --from ray@franco.ms \ --to ray@franco.ms \ --server smtp.protonmail.ch \ --port 587 \ --auth PLAIN \ --tls \ --auth-user 'ray@franco.ms' \ --auth-password 'XM42XFR6G2QC49QL' \ --header 'Subject: Test email' \ --body "This is a test email."
Got me past the authenification, but it gave me the following error:
~> AUTH PLAIN AHJheUBmcmFuY28ubXMAWE00MlhGUjZHMlFDNDlRTA== <~ 235 2.7.0 Authentication successful ~> MAIL FROM:<~ 250 2.1.0 Ok ~> RCPT TO: <~* 501 5.5.2 <50>: Helo command rejected: Invalid name ~> QUIT <~ 221 2.0.0 Bye === Connection closed with remote host. ./swak.sh: line 11: --header: command not found
Note that <50> in the error message is my hostname for the host I ran the command on.
After adding a --ehlo option (flag), I was able to successful send an email to myself through Proton Mail's smapt server. See below:
wa@50:~ $ cat swak.sh swaks \ --from ray@franco.ms \ --to ray@franco.ms \ --server smtp.protonmail.ch \ --port 587 \ --auth PLAIN \ --tls \ --auth-user 'ray@franco.ms' \ --auth-password 'XM42XFR6G2QC49QL' \ --ehlo 127.0.0.1 \ --header 'Subject: My 2nd Email' \ --body "This is my 2nd test email."
wa@50:~ $ ./swak.sh === Trying smtp.protonmail.ch:587... === Connected to smtp.protonmail.ch. <- 220 mailsub002.protonmail.ch ESMTP Postfix -> EHLO 127.0.0.1 <- 250-mailsub002.protonmail.ch <- 250-PIPELINING <- 250-SIZE 36480000 <- 250-STARTTLS <- 250-ENHANCEDSTATUSCODES <- 250-8BITMIME <- 250 CHUNKING -> STARTTLS <- 220 2.0.0 Ready to start TLS === TLS started with cipher TLSv1.3:TLS_AES_256_GCM_SHA384:256 === TLS no local certificate set === TLS peer DN="/CN=protonmail.com" ~> EHLO 127.0.0.1 <~ 250-mailsub002.protonmail.ch <~ 250-PIPELINING <~ 250-SIZE 36480000 <~ 250-AUTH PLAIN <~ 250-ENHANCEDSTATUSCODES <~ 250-8BITMIME <~ 250 CHUNKING ~> AUTH PLAIN AHJheUBmcmFuY28ubXMAWE00MlhGUjZHMlFDNDlRTA== <~ 235 2.7.0 Authentication successful ~> MAIL FROM:<~ 250 2.1.0 Ok ~> RCPT TO: <~ 250 2.1.5 Ok ~> DATA <~ 354 End data with . ~> Date: Thu, 03 Apr 2025 14:25:07 -0500 ~> To: ray@franco.ms ~> From: ray@franco.ms ~> Subject: My 2nd Email ~> Message-Id: <20250403142507.060868@50> ~> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/ ~> ~> This is my 2nd test email. ~> ~> ~> . <~ 250 2.0.0 Ok: queued as 4ZTBX528Csz44V ~> QUIT <~ 221 2.0.0 Bye === Connection closed with remote host
This worked !!!
Watchdog timers require counter. You can use a /dev/shm/file to store the count. For example:
echo 0 > /dev/shm/counter
Will create the file, counter, whose contents is zero.
You can then read the file counter into a varable, increment it, and write it back to the file, counter.
var=$(</dev/shm/counter)
echo $[$var+1] > /dev/shm/counter