Linux send test email
A classic!
To send a test email from a Linux terminal, you can use the mail
command or a more advanced tool like sendmail
or ssmtp
.
Method 1: Using the mail
command
- Open a terminal and type:
mail -s "Test Email" [email protected]
- Replace
[email protected]
with the email address you want to send the test email to. - You will be prompted to enter the email body. Type your message and press Enter.
- Press Enter again to send the email.
Method 2: Using sendmail
- Install
sendmail
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 [email protected] -t
- Replace
[email protected]
with the email address you want to send the test email to. - You will be prompted to enter the email body. Type your message and press Enter.
- Press Enter again to send the email.
Method 3: Using ssmtp
- Install
ssmtp
if it's not already installed:sudo apt-get install ssmtp
(on Ubuntu-based systems) orsudo yum install ssmtp
(on RHEL-based systems). - Configure
ssmtp
by editing the/etc/ssmtp/ssmtp.conf
file (on Ubuntu-based systems) or/etc/ssmtp/ssmtp.conf
(on RHEL-based systems). Set themailhub
option to your email provider's SMTP server. - Open a terminal and type:
ssmtp -v [email protected]
- Replace
[email protected]
with the email address you want to send the test email to. - You will be prompted to enter the email body. Type your message and press Enter.
- Press Enter again to send the email.
Remember to replace [email protected]
with your actual email address and email provider's SMTP server settings.