LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2005, 01:51 PM   #1
boopadedoo
LQ Newbie
 
Registered: Jul 2005
Location: California, USA
Posts: 1

Rep: Reputation: 0
mail


Hi,
In Unix I can use mailx to change the return address with the -r option, ie.
mailx -s "test" -r nobody someone@somecompany.com < /tmp/foo

How can I change the return address using mail or sendmail in Linux in a script.
 
Old 07-14-2005, 02:24 PM   #2
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Fairly simple - for example:
I've a script that runs on my website and lets me know when someone leaves me a comment. So, in my AddComment script, there's
Code:
    # Hijack the server's sendmail to send an email 
    MAIL = "/usr/sbin/sendmail"

    # get the email message from a file
    f = open('emailtext', 'r')
    message = f.read()
    f.close()

    #Let myself know the updated URL
    message = message + "\nhttp://www.cybermenology.com/Comments/" + filename

    # open a pipe to the mail program and
    # write the data to the pipe
    p = os.popen("%s -t" % MAIL, 'w')
    p.write(message)
    p.close()

    #Surprisingly enough, I don't really care what the exit code of the write() is.
    #if exitcode:
    #    print "Exit code: %s" % exitcode
The syntax for opening a system pipe may differ slightly depending on what language you're using. The above is python.

The actual text file containing the mail headers and the basic message is:
Code:
[laura@cybermenology.com]$ cat emailtext
To: my_email_address@yahoo.com
From: automated.process@cybermenology.com
Reply-to: laura@cybermenology.com
Subject: New comment

Email message ...words words words....shtufff...blah.
And that's all there is to it.

Last edited by rose_bud4201; 07-14-2005 at 02:25 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Sendmail forward all incoming mail to localhost port 26 (Domino mail) speedgelb Linux - Software 3 09-27-2013 11:18 AM
Configure & Connect a Linux mail server from a windows mail clients digihall7 Linux - Networking 4 10-23-2006 01:21 PM
sendmail error Fetching mail could not lock /var/spool/mail/username sukhdev50 Linux - Networking 0 05-04-2005 04:41 AM
Exists a mail-client for Fedora, that can read local mail file without deleting? mxn Linux - Software 1 07-10-2004 01:53 PM
parsing mail.log with perl and calculate mail traffic on domain base markus1982 Programming 1 03-18-2003 07:22 AM


All times are GMT -5. The time now is 04:17 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration