How to send a file as an email attachment using Linux command?

DWQA QuestionsCategory: LinuxHow to send a file as an email attachment using Linux command?
RevisitClass Staff asked 2 years ago

mailx command

mailx is a linux command which is used to send an email. This command is providing the option to add a file as an attachment.

mailx command syntax

echo “<mail_body>” | mailx -a “<file_name>” -s “<mail_subject>” <recipient_email_id>

send a file as an email attachment

echo “Script details” | mailx -a “run_hive_sql.sh” -s “Script to run the hive sql” peter22@gmail.com

Here we are trying to send a shell script file from linux machine to our mail box. We can run this command in the linux command line also.