How to send mail via ssmtp

SSMTP (Simple SMTP) is a lightweight and easy-to-use SMTP server that allows you to send emails from your Linux system. Here's a step-by-step guide on how to send mail via SSMTP:

Prerequisites:

  1. Install SSMTP on your Linux system. The package name may vary depending on your distribution:
    • Ubuntu/Debian: sudo apt-get install ssmtp
    • Red Hat/CentOS: sudo yum install ssmtp
    • Fedora: sudo dnf install ssmtp
  2. Configure your email account settings:
    • You'll need to know your email account's SMTP server address, username, and password.

Configuring SSMTP:

  1. Edit the SSMTP configuration file: sudo nano /etc/ssmtp/ssmtp.conf
  2. Update the following settings:
    • mailhub: Set this to your email provider's SMTP server address (e.g., smtp.gmail.com for Gmail).
    • FromLineOverride: Set this to YES to override the default "From" address.
    • AuthUser and AuthPass: Set these to your email account's username and password, respectively.
  3. Save and exit the editor.

Sending an email using SSMTP:

  1. Use the ssmtp command to send an email:
    • ssmtp -v [email protected] "Subject: Test email" "Body of the email"
    • Replace [email protected] with the recipient's email address, and Subject and Body with your desired subject and message.
    • The -v flag enables verbose mode, which can help you troubleshoot any issues.
  2. If everything is configured correctly, you should receive the email at the specified recipient's address.

Tips and Variations:

Remember to replace the placeholders with your actual email account settings and recipient information. If you encounter any issues, refer to the SSMTP documentation or seek help from your email provider's support team.