How to send a mail with attachment in linux

There are several ways to send a mail with an attachment in Linux. Here are a few methods:

Method 1: Using mutt command

You can use the mutt command-line email client to send a mail with an attachment. Here's an example:

mutt -s "Subject" [email protected] -a attachment_file.txt

Replace Subject with the subject of your email, [email protected] with the recipient's email address, and attachment_file.txt with the name of the file you want to attach.

Method 2: Using mail command

You can use the mail command to send a mail with an attachment. Here's an example:

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

Replace Subject with the subject of your email, [email protected] with the recipient's email address, and attachment_file.txt with the name of the file you want to attach.

Method 3: Using sendmail command

You can use the sendmail command to send a mail with an attachment. Here's an example:

sendmail -t -i -f [email protected] [email protected] < attachment_file.txt

Replace [email protected] with your email address, [email protected] with the recipient's email address, and attachment_file.txt with the name of the file you want to attach.

Method 4: Using msmtp command

You can use the msmtp command to send a mail with an attachment. Here's an example:

msmtp -a attachment_file.txt -s "Subject" [email protected]

Replace Subject with the subject of your email, [email protected] with the recipient's email address, and attachment_file.txt with the name of the file you want to attach.

Method 5: Using a GUI email client

You can also use a GUI email client like Evolution, Thunderbird, or KMail to send a mail with an attachment. These clients usually have a built-in attachment feature that allows you to select a file to attach.

Tips