OpenWaterFoundation / owf-app-snodas-ng

Open Water Foundation SNODAS snowpack user interface built with Angular
0 stars 0 forks source link

Implement sendmail command #28

Open Nightsphere opened 2 years ago

Nightsphere commented 2 years ago

Sendmail Setup

Website used for reference and help:

https://blog.edmdesigner.com/send-email-from-linux-command-line/

Check if sendmail is installed

Verify installation

Configuring the SSMTP configuration file

# Use TLS before starting negotiation.
UseSTARTTLS=YES
# The user that gets the emails.
root=<user@email.com>
# The mail server (where the mail is sent to), both port 465 or 587 should be
# acceptable. See also https://support.google.com/mail/answer/78799
mailhub=smtp.gmail.com:587
# The address where the mail appears to come from for user authentication.
rewriteDomain=gmail.com
# Username/App password for less secure apps.
AuthUser=<user@email.com>
AuthPass=lessSecureAppPassword

NOTE: This is using the gmail smtp server, which will need Google authentication to succeed. From what I've tested, using the actual Google account password will not work, since this is considered a "less secure app". 2FA will need to be turned on to enable a less secure app password. Documentation can be found here.

NOTE 2: I could not find a way to use the built in Windows email so authentication isn't needed. Steve had suggested using this way previously for the Sendmail command in TSTool, but I'm not sure how that would work on the GCP VM.

Sending an email

To: <user@email.com>
Subject: <My Subject>
From: <user@email.com>
CC: <user@email.com>
BCC: <user@email.com>

This is the email body. You can write your message here, and all previously
added headers above will be cut out of the final message.

Thanks,

A friend.
sendmail -t < mail.txt

Sending HTML in an email

Populating the contents of an email with HTML is an option as well by adding Content-Type: text/html: charset="utf8" under the headers of the email. Adding HTML in the message body can then be added and sent. For example:

To: <user@email.com>
Subject: Test email
From: <user@email.com>
Content-Type: text/html; charset="utf8"

<html>
  <body>
    <div style="
      background-color: #ff0000;
      width: 300px;
      display: inline-block;
      height: 300px;">
    </div>
      You can add any valid email HTML here.
  </body>
</html>