How to send mail using smtp in linux
To send mail using SMTP in Linux, you can use the sendmail
command or a mail client like mutt
or msmtp
. Here are the steps:
Using sendmail
- Install the
sendmail
package if it's not already installed:sudo apt-get install sendmail
(on Ubuntu-based systems) orsudo yum install sendmail
(on RHEL-based systems). - Open a terminal and type:
sendmail -v -f your_email_address recipient_email_address
-v
enables verbose mode, which shows the SMTP conversation.-f
specifies the sender's email address.your_email_address
is the email address you want to use as the sender.recipient_email_address
is the email address you want to send the mail to.
- You will be prompted to enter the subject and body of the email. Type them in and press Enter.
Using mutt
- Install the
mutt
package if it's not already installed:sudo apt-get install mutt
(on Ubuntu-based systems) orsudo yum install mutt
(on RHEL-based systems). - Open a terminal and type:
mutt -s "Subject" recipient_email_address
-s
specifies the subject of the email.Subject
is the subject you want to use.recipient_email_address
is the email address you want to send the mail to.
- You will be prompted to enter the body of the email. Type it in and press Enter.
Using msmtp
- Install the
msmtp
package if it's not already installed:sudo apt-get install msmtp
(on Ubuntu-based systems) orsudo yum install msmtp
(on RHEL-based systems). - Configure msmtp by creating a configuration file in your home directory:
nano ~/.msmtprc
- Add the following lines to the file:
defaults auth on tls on from your_email_address
defaults
specifies the default settings.auth on
enables authentication.tls on
enables TLS encryption.from your_email_address
specifies the sender's email address.
- Save and close the file.
- Open a terminal and type:
msmtp -v recipient_email_address
-v
enables verbose mode, which shows the SMTP conversation.recipient_email_address
is the email address you want to send the mail to.
- You will be prompted to enter the subject and body of the email. Type them in and press Enter.
Using a mail client like Thunderbird
- Install Thunderbird if it's not already installed:
sudo apt-get install thunderbird
(on Ubuntu-based systems) orsudo yum install thunderbird
(on RHEL-based systems). - Open Thunderbird and create a new email.
- Enter the recipient's email address, subject, and body.
- Click the "Send" button to send the email.
Note: Make sure you have a working SMTP server and that your email account is configured correctly.