
In case while sending the email, if might get the below error as output:

Hope now you're able to send mails using the shell script too.īelow are few errors/exceptions which you may encounter while sending the mail using ssmtp: Error 1 Just run the shell script using the below command: $ sudo. If not, here is the command to set the permission: $ sudo chmod 755 mail.sh Make sure you have set the right permission access to your script file. For that, open your preferred editor and create a shell script file with name saymail.shand copy-paste the below code: #!/bin/sh You can use the same ssmtp to send mail from a shell script too. vvv is the verbosity to see the logs while sending the mail Case 2: Send Mail From A Shell Script Case 1: Send Mail Directly From The Command Lineįor this, copy-paste the below command, and you're ready to send email from your command line: echo "Test message from Linux server using ssmtp" | sudo ssmtp -vvv There are multiple ways to use ssmtp command to send emails.

Now you are all set to sending mails from the command line (CLI). mailhub is used for SMTP server address which consists of two part host:port if you want to use Pepipost SMTP, then instead of, you need to mention in the mailhub parameter. In case you want to use some other third-party SMTP, then mention the hostname of the same. The above configuration is going to be used to send email using your Gmail SMTP. TLS_CA_File=/etc/pki/tls/certs/ca-bundle.crt Open the following file in your favourite editor: sudo vim /etc/ssmtp/nfĮdit the above file with the below details: mailhub=:587 Once ssmtp installed successfully, you need to make the below global configurations which required for sending mail.
#UBUTNTU SEND MAIL USING SSMTP FROM PHP INSTALL#
In CentOS, you may see an error during installation as "package ssmtp is not available", in such a case below command, is going to be helpful to fix the issue: sudo yum -enablerepo=extras install epel-release Use the below command to install ssmtp: sudo apt-get install ssmtpĬentOS users can use the below command to install ssmtp: sudo yum install ssmtp
#UBUTNTU SEND MAIL USING SSMTP FROM PHP HOW TO#
How to install sSMTP to send mails from your Linux command line (CLI) Step 1 Click here, in case you want to learn how to install and use Mailx to send mails from your Linux command line. In this tutorial, you're going to learn the steps on how to install and use sSMTP to send mails from your Linux command line. There are various tools and libraries which you can install to send emails from the terminal. Google SMTP server configurations would look something like this: In this tutorial, you are going to use Gmail SMTP to send emails, so make sure that

This tutorial is going to help you in sending critical server-level emails like Cron reports, script logs, customer registrations, receipt, bank statement over email. You are going to learn the process of sending emails from the terminal or a shell script from a Linux operating system, using some of the popular CLI tools. This tutorial is going to demonstrate you the simplest way of sending notifications, over one of the most popular channels that is email. Moreover, these notifications can be emails, SMS or push. Notifications are getting more important these days to stay updated among various online activities. The author voluntarily contributed this tutorial as a part of Pepipost Write to Contribute program.
