954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sending email from a shell script

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!

leoman
Newbie Poster
2 posts since Dec 2004
Reputation Points: 10
Solved Threads: 0
 

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

I usually just use sendmail directly, like this:

sendmail [email]email@domain.com[/email] < ~/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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

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

sendmail: not found

How can I solve this?

Thanks!

leoman
Newbie Poster
2 posts since Dec 2004
Reputation Points: 10
Solved Threads: 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 usingmail instead of sendmail, too.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 
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

heema
Newbie Poster
1 post since Jan 2005
Reputation Points: 10
Solved Threads: 0
 

One command does it all ~ :p

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

YUPAPA
Light Poster
42 posts since Dec 2004
Reputation Points: 10
Solved Threads: 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 [email]sanju456@rediffmail.com[/email]. Sanjeev

sanju456
Newbie Poster
2 posts since Jan 2005
Reputation Points: 10
Solved Threads: 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 [email]pagernumber@skytel.com[/email] , nothing happens.
Can somebody please help ?

Thanks
Deepika

dmellach
Newbie Poster
1 post since Apr 2005
Reputation Points: 10
Solved Threads: 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

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

Thanks

rexwint
Newbie Poster
2 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

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

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 

Hey Shanenin,

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

Thanks,

RexWint

rexwint
Newbie Poster
2 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

I personally have never used mail or sendmail.

shanenin
Posting Whiz in Training
217 posts since May 2005
Reputation Points: 10
Solved Threads: 17
 
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

bugmenot
Posting Whiz in Training
225 posts since Nov 2006
Reputation Points: 53
Solved Threads: 34
 

One command does it all ~ :p

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

I tried the same but when the mail is send ... The from address is diffirent like
How to solve this

Mithun.kamath
Newbie Poster
2 posts since May 2008
Reputation Points: 10
Solved Threads: 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

eggi
Posting Pro in Training
400 posts since Oct 2007
Reputation Points: 102
Solved Threads: 47
 

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.

oppiet30
Newbie Poster
1 post since Jun 2009
Reputation Points: 10
Solved Threads: 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.

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

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]

KlementHonza
Newbie Poster
8 posts since Apr 2009
Reputation Points: -12
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You