Amazon SES (Simple Email Service) is a popular SMTP service provider similar to Sendgrid, Mailchimp, etc. In order to use SES, you need to signup for an Amazon Web Services account. Which is the leading Cloud-based service provider. Post signup you need to add your credit card for the billing. The default SES allows sending 2000 emails/day freely. After the default limit, you will be charged as pay-per-use.

Advertisement

In this blog post, you will learn to send emails via Amazon SES or any other SMTP provider from a bash shell or script.

Pre-Requisiteis

  • In this tutorial, we used the SendEmail command line SMTP client for sending emails. So you must have installed SendMail on your system.
  • You must have verified the email address or the domain name under Verified Identities in Amazon SES. When the domain is verified, you can use any email address while sending emails
  • All the new accounts in the Amazon SES are in sandbox mode for security purposes. You need to submit a request to support converting the SES account to production mode.

Shell Script for Sending Emails via SMTP

I have written a small shell script that sends emails via the remote SMTP servers. It uses the SendEmail SMTP client. Use any of the popular SMTP providers (like Sendgrid, Amazon SES, and Mailchimp) with this shell script. You can also integrate this shell script code into your existing shell scripts for sending emails properly.

In the above script, the Mailcontent.txt file contains the mail body content.

Conclusion

Shell scripts are an important part of system administration. It helps us to automate tasks quickly like scheduling backups, archiving logs and collecting data, etc. Sometimes we are also required to send emails from shell scripts. In this tutorial, you have learned to send emails via the Amazon SES server. Even you can also use this script with any other SMTP providers.

Share.
Leave A Reply


Exit mobile version