Send mail cli
You want to send an email using the command line (CLI)!
There are several ways to do this, depending on your operating system and email client. Here are a few options:
Option 1: Using the mail
command ( Unix-like systems)
You can use the mail
command to send an email from the command line. Here's an example:
mail -s "Subject" [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the recipient.
Option 2: Using sendmail
( Unix-like systems)
You can use the sendmail
command to send an email from the command line. Here's an example:
sendmail -t -i -f your_email_address [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the recipient.
Option 3: Using msmtp
(Windows and Unix-like systems)
You can use the msmtp
command-line email client to send an email from the command line. Here's an example:
msmtp -a your_email_address -t -c "Subject" [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the recipient.
Option 4: Using mutt
(Unix-like systems)
You can use the mutt
command-line email client to send an email from the command line. Here's an example:
mutt -s "Subject" [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the recipient.
Option 5: Using a third-party email client (e.g., Gmail)
If you have a Gmail account, you can use the curl
command to send an email from the command line. Here's an example:
curl -X POST \
https://smtp.gmail.com:587/ \
-u your_email_address:your_password \
-H 'Content-Type: text/plain' \
-d 'Subject: Your subject\r\n\r\nYour email body'
Replace your_email_address
and your_password
with your actual Gmail credentials. This will send an email to the recipient.
Remember to replace [email protected]
with the actual email address of the person you want to send the email to.