LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-25-2001, 08:46 AM   #1
bfloeagle
Member
 
Registered: Jun 2000
Location: Upstate New York
Distribution: Ubuntu
Posts: 158

Rep: Reputation: 30
Question Script to send email...


What commands would you put into a bash script to send an email to somebody?
 
Old 08-25-2001, 08:55 AM   #2
Skot
LQ Newbie
 
Registered: Jul 2001
Distribution: LMdk 7.x mostly
Posts: 19

Rep: Reputation: 0
mail

mail -s "some subject" bofh@ualberta.edu < some_text_file
 
Old 10-13-2009, 08:14 AM   #3
pbxuser911
LQ Newbie
 
Registered: Oct 2009
Location: USA
Posts: 12

Rep: Reputation: 0
how can i add which email address it will display its coming from?
 
Old 10-13-2009, 08:32 AM   #4
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by pbxuser911 View Post
how can i add which email address it will display its coming from?
Code:
/usr/sbin/sendmail -f from@test.com  to@test.com < file

OR

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;


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

Last edited by centosboy; 10-13-2009 at 08:37 AM.
 
Old 10-13-2009, 10:15 AM   #5
bfloeagle
Member
 
Registered: Jun 2000
Location: Upstate New York
Distribution: Ubuntu
Posts: 158

Original Poster
Rep: Reputation: 30
Glad to see this thread is still kicking 8 years later.
 
Old 10-13-2009, 10:20 AM   #6
pbxuser911
LQ Newbie
 
Registered: Oct 2009
Location: USA
Posts: 12

Rep: Reputation: 0
echo "body of message" | mailx -s "subject line" emailto@mail.com -- -r emailfrom@mail.com < includefile.txt

how do i put a name ? when outlook gets the email it shows emailfrom@mail.com i want it to say Email From but when you click show address it will show emailfrom@mail.com
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
email 'send' YES - email 'receive' NO..? captain skywave Linux - Wireless Networking 1 04-22-2005 05:23 AM
write a shell script to send email yenonn Programming 4 02-11-2005 10:06 PM
Write a script to send an email from bash kpelczar Linux - Software 5 02-09-2005 04:19 PM
Allowing an IP to send email using my email server... culprit Linux - Networking 7 09-09-2003 12:24 PM
script to send email message meluser Programming 2 03-26-2003 12:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration