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

From: Hobbs, Richard <hobbs_at_mongeese.co.uk>
Date: Thu Oct 16 2003 - 18:07:44 EDT
Hello,

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:

===============================================================================
<?php

$headers = "From: Firstname Secondname <fromaddr@domain.com>\n";
$headers .= "X-From: Firstname Secondname <fromaddr@domain.com>\n";
$headers .= "Reply-to: Firstname Secondname <fromaddr@domain.com>\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.
END;

mail( 'toaddr@domain.com', 'Test Message', $message, $headers );

?>
===============================================================================

and it works perfectly!! :-)

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

Hobbs.


Quoting "Hobbs, Richard" <hobbs@mongeese.co.uk>:

> 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' hobbs@mongeese.co.uk < /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            http://unixforum.co.uk     http://mongeese.co.uk
hobbs_at_mongeese.co.uk                                http://fishsponge.co.uk
____________________________________________________________________________
Would you like jokes in your email?   Email jokes-subscribe@fishsponge.co.uk
Would you like to discuss unix/linux? Email ufq-subscribe@unixforum.co.uk
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
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