“mailx” is the utility to send emails from Solaris to the outside world. Emails can be sent in many formats:
(1) Contents of file in email as text:
# mailx -s 'Subject-Here' abc@xyz.com < input.file
# mailx -s 'Uptime Report' abc@xyz.com < /tmp/output.txt
Where,
-s ‘Subject’: Specify subject on command line.
abc@xyz.com: To email user.
/tmp/output.txt: Send the content of /tmp/output.txt file using mail command.
(2) Attaching a file as an “attachment” to the email
Example: Attach /tmp/list.tar.gz and and send it
# uuencode /tmp/list.tar.gz /tmp/list.tar.gz | mailx -s "Reports" abc@xyz.com
(3) Attaching a file as an “attachment” and contents of a file as body of the email
Example: Email photo.png along with a text message read from body.txt
# (cat body.txt; uuencode photo.png photo.png) | mailx -s "Subject" abc@xyz.com
(4) Attaching multiple files as “attachments”
Example: Email files - file1.doc, file2.doc & file3.doc – to a single email.
# (uuencode file1.doc file1.doc; uuencode file2.doc file2.doc; uuencode file3.doc file3.doc) | mailx -s "Subject" abc@xyz.com
Above commands can be scripted to send emails from the system:
1. As alerts to the system admins, on adhoc – on-event-basis.
2. As Periodic/scheduled emails – performance reports, healthcheck reports
3. On need basis
No comments:
Post a Comment