Linux send mail without sendmail

There are several ways to send mail from a Linux system without using the traditional Sendmail or Postfix mail transfer agents. Here are a few options:

  1. mail command: The mail command is a simple way to send email from the command line. You can use it to send a plain text email to a recipient.

Example:

mail -s "Subject" [email protected] < message.txt

This will send a plain text email with the subject "Subject" and the contents of the file message.txt to the recipient [email protected].

  1. sendmail alternative: You can use the mpack command to send a mail message. mpack is a command-line mail client that can send mail using a variety of protocols, including SMTP.

Example:

mpack -s "Subject" [email protected] < message.txt

This will send a plain text email with the subject "Subject" and the contents of the file message.txt to the recipient [email protected].

  1. ssmtp package: ssmtp is a simple SMTP client that can be used to send mail from the command line. You can install it on most Linux distributions.

Example:

ssmtp -t [email protected] < message.txt

This will send a plain text email with the contents of the file message.txt to the recipient [email protected].

  1. msmtp package: msmtp is another SMTP client that can be used to send mail from the command line. You can install it on most Linux distributions.

Example:

msmtp -t [email protected] < message.txt

This will send a plain text email with the contents of the file message.txt to the recipient [email protected].

  1. Python's smtplib library: You can use Python's smtplib library to send mail programmatically.

Example:

import smtplib
from email.mime.text import MIMEText

msg = MIMEText("Hello, world!")
msg['Subject'] = "Hello, world!"
msg['From'] = "[email protected]"
msg['To'] = "[email protected]"

server = smtplib.SMTP('smtp.example.com')
server.sendmail("[email protected]", "[email protected]", msg.as_string())
server.quit()

This will send a plain text email with the subject "Hello, world!" and the contents "Hello, world!" to the recipient [email protected] using the smtp.example.com SMTP server.

Note that these methods may not be as robust or feature-rich as using a traditional mail transfer agent like Sendmail or Postfix, but they can be useful for simple email sending tasks.