Sendmail linux attachment

The classic sendmail command!

To send an email with an attachment using sendmail on Linux, you can use the following syntax:

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

Here's a breakdown of the options:

The message.txt file should contain the email message, including the attachment, in the following format:

Subject: My Email Subject

This is my email message.

Attachment: attachment.txt
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="attachment.txt"

[contents of attachment.txt]

Here's an example of a complete message.txt file:

Subject: My Email Subject

This is my email message.

Attachment: attachment.txt
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment; filename="attachment.txt"

This is the contents of the attachment.txt file.

Save the message.txt file and then run the sendmail command:

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

This will send the email with the attachment to the specified recipient.

Note: Make sure to replace [email protected] and [email protected] with your actual email addresses. Also, adjust the message.txt file to include the correct attachment and email message.