Script to Send eMail 

Question:
What commands would you put into a bash script to send an email to somebody?

mail -s "some subject" someone@domain.edu < some_text_file
 

How can I add which email address it will display its coming from?

Simple perl will do it :

Code:

#!/usr/bin/perl

use strict;
use warnings;
my @body = `cat file.txt`;

open MAIL, "|/usr/sbin/sendmail -t user\@host.net\n"  or die "cannot open sendmail program: $!\n";
print MAIL "From: user\@host.net\n";
print MAIL "Cc: user\@host.net\n";
print MAIL "Subject: subject\n";
print MAIL "\n";
print MAIL  "@body\n";

close MAIL;

PS: file.txt can hold the contents of the email and be in the same directory as the script itself.

Have a Linux Problem
Linux Forum - Do you have a Linux Question?

Linux Books
Linux Certification, System Administration, Programming, Networking Books

Linux Home: Linux System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.