1,105,169 Community Members

Sending email from a shell script

Member Avatar
leoman
Newbie Poster
2 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

have written a shell script in which I use fastmail to send emails from the shell script.
It sends email to my company account with no problem. But I wan to send the same email to a pager number so that the pager goes off when the particular condition occurs.
I see that email is not being send to the pager from this script.

I tried sending email from my company email account to the pager email and the pager goes of with the email from company email account.

Any idea why this might be happening so? Is there anything else that I should use to send emails to pager

Thanks!

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
0
 

What's the script? (be sure to edit out the email addresses)

I usually just use sendmail directly, like this:

sendmail email@domain.com < ~/maildir/mailmessage

and that works out just fine, never had a problem. You could even use a variable if you wanted:

sendmail $email_addy < ~/maildir/mailmessage

That's always worked for me, assuming that your MTA is sendmail, or it is at least available.

Member Avatar
leoman
Newbie Poster
2 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thanks for your reply.
I tried using sendmail and it gave me error --

sendmail: not found

How can I solve this?

Thanks!

Member Avatar
alc6379
Cookie... That's it
2,752 posts since Dec 2003
Reputation Points: 105 [?]
Q&As Helped to Solve: 154 [?]
Skill Endorsements: 4 [?]
Team Colleague
 
0
 

Thanks for your reply.
I tried using sendmail and it gave me error --

sendmail: not found

How can I solve this?

Thanks!

Install sendmail? try using mail instead of sendmail, too.

Member Avatar
heema
Newbie Poster
1 post since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

have written a shell script in which I use fastmail to send emails from the shell script.
It sends email to my company account with no problem.

could you please post your script

Member Avatar
YUPAPA
Light Poster
42 posts since Dec 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

One command does it all ~ :p

echo "Message Content" | mail -s "Subject goes here" you@domain-name.com

Member Avatar
sanju456
Newbie Poster
2 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi Leoman,
I dont know the solution of this problem and i want a help form you that how to send email from shell script on linux to other email accounts. Can u send me the code at sanju456@rediffmail.com. Sanjeev

Member Avatar
dmellach
Newbie Poster
1 post since Apr 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi,

I have the same problem as Leoman. I am unable to see the solution on the forums.
This is my scenario:
I am trying to send an email to a pager through the shell script on linux. I am able to send an email to an email address from my script as well as from the command line. But, using the same mail command to page myself, fails. Nothing really happens. I don't get paged either from the command line or from my script.
Following is my command :
print "$user, $MESSAGE, $SERVER, `date`" | mail -s "Application $LEVEL PROBLEM" $pager_number
when I replace pager_number with an email address, it works perfectly but when I replace it with a pager number in the format pagernumber@skytel.com , nothing happens.
Can somebody please help ?

Thanks
Deepika

Member Avatar
rexwint
Newbie Poster
2 posts since Jul 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have been able to send email from the command line to localhost.localdomain, but when I try to send to my own email account at mindspring.com. it does not deliver to my email inbox. Instaed, I get an error message from mindspring.com that says:

Diagnostic-Code; SMTP: 550 Dynamic IPs/open relays blocked
Contact <openmailrelay@abuse.earthlink.net>

Anybody know a way to get around this and get my message deliverd to my inbox at mindspring.com ?

Thanks

Member Avatar
shanenin
Posting Whiz in Training
229 posts since May 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 1 [?]
 
0
 

it seems earthlink is trying to prevetn spam. That may be tough to get around

Member Avatar
rexwint
Newbie Poster
2 posts since Jul 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey Shanenin,

Is ther a way to use Linux Sendmail or Mail to send a message to an IP address ?

Thanks,

RexWint

Member Avatar
shanenin
Posting Whiz in Training
229 posts since May 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 1 [?]
 
0
 

I personally have never used mail or sendmail.

Member Avatar
bugmenot
Posting Whiz in Training
223 posts since Nov 2006
Reputation Points: 25 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

have written a shell script in which I use fastmail to send emails from the shell script.
It sends email to my company account with no problem. But I wan to send the same email to a pager number so that the pager goes off when the particular condition occurs.
I see that email is not being send to the pager from this script.

I tried sending email from my company email account to the pager email and the pager goes of with the email from company email account.

Any idea why this might be happening so? Is there anything else that I should use to send emails to pager

Thanks!

f

Member Avatar
Mithun.kamath
Newbie Poster
2 posts since May 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

One command does it all ~ :p

echo "Message Content" | mail -s "Subject goes here" you@domain-name.com

I tried the same but when the mail is send ... The from address is diffirent like <yourlogin@yourmachinename.local>
How to solve this

Member Avatar
eggi
Posting Whiz
399 posts since Oct 2007
Reputation Points: 92 [?]
Q&As Helped to Solve: 47 [?]
Skill Endorsements: 0 [?]
 
0
 

Hey There,

You can try piping everything to sendmail -t (mail and mailx use sendmail). The -t flag means you have to specify headers, though, so:

(echo "Subject: My Subject";echo "From: my@address.com";echo "To: your@address.com";echo "Reply-To: my@address.com";echo "X-Whatever: Any Other Headers You Want To Include";echo CONTENT;cat FILE)|/usr/lib/sendmail -t

sendmail might be in /usr/sbin/ also.

All the header information, CONTENT and FILE are just placeholders. Hopefully that will help you out. You may see an error in your syslog that the "sender was forced with -f" but that should be okay unless your mailserver won't accept it.

Best wishes,

Mike

Member Avatar
oppiet30
Newbie Poster
1 post since Jun 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I would like to send mail to myself using a for loop.
Like I would like to send email to myself 100 times with a bash shell script. I use to have a script that does this, but I seem to have lost it.

Member Avatar
sknake
Senior Poster
3,957 posts since Feb 2009
Reputation Points: 1,620 [?]
Q&As Helped to Solve: 747 [?]
Skill Endorsements: 25 [?]
Featured
 
0
 

I would like to send mail to myself using a for loop.
Like I would like to send email to myself 100 times with a bash shell script. I use to have a script that does this, but I seem to have lost it.

This thread is over four years old. Please start a new thread to ask your questions.

Member Avatar
KlementHonza
Newbie Poster
8 posts since Apr 2009
Reputation Points: -22 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

I am trying to write a shell script that evaluates the size of each user's home directory and if it is greater than 50 MB I want an email to be sent to their user account telling them that they need to reduce the size of their home directory.

url=http://"www.accessbit.com"Atlanta Professional Web Development[/url]

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article