Mailx example with attachment

Here is an example of using the mailx command to send an email with an attachment:

Example:

mailx -s "Example Email with Attachment" [email protected] << EOF
Subject: Example Email with Attachment

This is an example email with an attachment.

Attachment: example.txt
EOF

In this example:

Note: The attachment file example.txt should be in the same directory as the command is run from.

Example with multiple attachments:

mailx -s "Example Email with Multiple Attachments" [email protected] << EOF
Subject: Example Email with Multiple Attachments

This is an example email with multiple attachments.

Attachment: example1.txt
Attachment: example2.txt
Attachment: example3.txt
EOF

In this example, we are attaching three files: example1.txt, example2.txt, and example3.txt.

Example with a file in a different directory:

mailx -s "Example Email with Attachment" [email protected] << EOF
Subject: Example Email with Attachment

This is an example email with an attachment.

Attachment: /path/to/example.txt
EOF

In this example, we are attaching a file located at /path/to/example.txt. Make sure to specify the full path to the file.

Note: The mailx command may not work as expected if you are using a modern email client or a web-based email service. In that case, you may need to use a different command or tool to send emails with attachments.