SUMMARY: Specifying "From" addr when emailing from a cronjob

From: Hobbs, Richard <>
Date: Thu Oct 16 2003 - 18:07:44 EDT

Many thanks to everyone who replied... but due to the nature of my ISP's 
configurations and the fact that they're running RedHat, not Solaris (which i 
didn't think would be relevant initially, but indeed it was), i've settled for 
a different method of going about it - PHP.

I put a PHP script into my webspace, and the cronjob calls it as:

  php /path/to/file.php

The contents of the PHP script are:


$headers = "From: Firstname Secondname <>\n";
$headers .= "X-From: Firstname Secondname <>\n";
$headers .= "Reply-to: Firstname Secondname <>\n";

$message =<<<END
This is the first line of the email body.
This is the second line.

and the fourth line.
This is the fifth and final line.

mail( '', 'Test Message', $message, $headers );


and it works perfectly!! :-)

Thanks to everyone who helped, it was still very useful :-)


Quoting "Hobbs, Richard" <>:

> Hello,
> First of all... apologies if this isn't as Solaris-related as some of the 
> problems on here, but this still seemed like the best place to ask for help.
> I have a cronjob that automatically sends the contents of a file as the body
> of 
> an email each month. The problem is that it uses the default "From" address 
> (which is the username@localmachine). I therefore need to specify my own
> "From" 
> address. here's the command i'm currently using:
>   mail -s 'Test' < /home/textFile
> Setting the Reply-To isn't good enough, because i want to use this command to
> email subscribers on my mailing list. My list only allows emails if the
> "From" 
> address specified is also subscribed.
> My linux box has a "-a" option that allows me to specify my own headers on
> the 
> cmdline, but the version i'm using on my server doesn't allow this.
> Any ideas??
> Thanks in advance,
> Hobbs.

Richard Hobbs                        
Would you like jokes in your email?   Email
Would you like to discuss unix/linux? Email
sunmanagers mailing list
Received on Thu Oct 16 18:07:39 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:22 EST