473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Send mail via shell script

krik
1
Hello,

I would like to send a mail via a script with customized From field or at least with Reply-To. This email is sent by a monitoring server via a cron job and the users should see this mail as coming from the group mailbox I belong to.

I haven't been able to find how to send a mail with a different address in the From but from the command line I can change the Reply-to (better than nothing). If I use the same in a script it doesn't work... Here is what I did :

Expand|Select|Wrap|Line Numbers
  1. myserver> mail -s 'test mail' destination@test.org
  2. ~R reply.here@test.org
  3. content of the message
  4. .
  5. EOT
This works fine, the reply-to is correctly set. Now, the script I wrote :


Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/bash
  2. cat << EOF | mail -s 'test mail' destination@test.org
  3. ~R reply.here@test.org
  4. content of the message
  5. EOF
With this script I receive the mail with the ~R line in the body and the reply-to is not set...

Any idea why this behaviour? Any idea how to set the from field?

Thanks,
Krik
Oct 26 '07 #1
2 22979
Hello,

I would like to send a mail via a script with customized From field or at least with Reply-To. This email is sent by a monitoring server via a cron job and the users should see this mail as coming from the group mailbox I belong to.

I haven't been able to find how to send a mail with a different address in the From but from the command line I can change the Reply-to (better than nothing). If I use the same in a script it doesn't work... Here is what I did :

Expand|Select|Wrap|Line Numbers
  1. myserver> mail -s 'test mail' destination@test.org
  2. ~R reply.here@test.org
  3. content of the message
  4. .
  5. EOT
This works fine, the reply-to is correctly set. Now, the script I wrote :


Expand|Select|Wrap|Line Numbers
  1. #!/usr/local/bin/bash
  2. cat << EOF | mail -s 'test mail' destination@test.org
  3. ~R reply.here@test.org
  4. content of the message
  5. EOF
With this script I receive the mail with the ~R line in the body and the reply-to is not set...

Any idea why this behaviour? Any idea how to set the from field?

Thanks,
Krik

Use mailx command. Example:
mailx -s "Subject" mail-id's to send < file.txt
Dec 3 '07 #2
rhXX
1
try option -I

Expand|Select|Wrap|Line Numbers
  1.       #!/usr/local/bin/bash
  2.       mail -I -s 'test mail' toto@toto.com <<EOF
  3.       ~R toto1@toto.com
  4.       content of the message
  5.       EOF
  6.  

question:

does tilde escape ~R exist?????

i didn't find it, and my mail / mailx doesn't recognize it ?????

i would appreciate your comments
Jul 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: ambs.tech | last post by:
Hi all, Is there any way to read a email address from a text file and send email to that address using C language. any hint or any code regarding this will be very helpful. Thanks, Ambika
3
by: bikkaran | last post by:
Hi I have a function as below... function PerformQuery3 { $VAR1 = 'export to $1 of ixf messages $2.out "select * from $3"' echo $VAR1 SQL_CODE=$(db2 -ec +o $1) if ]
1
by: news | last post by:
At the end of a PHP script, I'm sending a file via FTP to a server. I thought it'd be best to use a shell script in order to automate the FTP (logging in, changing to binary, putting the file,...
7
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? ...
1
by: vijayandc | last post by:
All, I am working in an linux system, i want to send mail from my linux system to yahoo id using shell script. How to do that? Pls advice me.
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
2
by: DVH | last post by:
Hi, I've a script that sends mail from my site. I've included a regexp which should return 403 forbidden if you try to hijack it and send to another address. How can I test to make sure it...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: Marco Bizzarri | last post by:
On Wed, Nov 12, 2008 at 2:06 PM, devi thapa <devi.thapa@gmail.comwrote: import sys sys.exit(123) -- Marco Bizzarri
1
by: priyankapendkar | last post by:
Hi, #! /bin/bash x=50 if then mail -s "$x is greater than 25" email@address fi
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.