Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Perl-based Newsletter Script Needs Your Help

by nickcave25 (Acolyte)
on Jul 13, 2000 at 14:03 UTC ( [id://22342]=perlquestion: print w/replies, xml ) Need Help??

nickcave25 has asked for the wisdom of the Perl Monks concerning the following question:

Hello. I am getting ready to put the finishing touches on a Perl-based subscription newsletter mailing program.

It sends off a message to a selected address as it steps through an array of email addresses. Nothing fancy.
Here's the part I need help with:

open handleMAIL, "|mail $someAddress"; print handleMAIL "This here is the content."; print handleMAIL "etc."; close handleMAIL;
where $someAddress equals theuser\@herdomain.com

It's going to run on a BSDI BSD OS 3.1 system (running Stronghold/2.2 Apache/1.2.5 C2NetUS/2004) (not as a daemon, just when I flip the switch.)

THE PROBLEM I am faced with is that anything mailed this way shows up as coming from the actual username for the account I have access to (a cryptic string of characters and numbers) instead of something user-friendly like "newsletter@ourdomain.com".

Are there any parameters I can add to the  open handleMAIL, "|mail $someAddress"; statement to cause the FROM address to display the more user-friendly address. Or is there some other way to specify the FROM address.

Any suggestions will be appreciated in a major way.

If I can fix this one issue, it will mean yet another victory for Perl within my somewhat Micros~1-centric workplace.

Thanks.

Replies are listed 'Best First'.
Re: Perl-based Newsletter Script Needs Your Help
by le (Friar) on Jul 13, 2000 at 14:12 UTC
    Why not using any of the Mail::* modules? I can't remember exactly, but Mail::Sendmail or Mail::Mailer lets you specify several headers.

    Update:
    use Mail::Mailer; $mailer = new Mail::Mailer; $mailer->open(\%headers); print $mailer $body; $mailer->close;
    So you can have your headers in the %headers hash.
Re: Perl-based Newsletter Script Needs Your Help
by c-era (Curate) on Jul 13, 2000 at 15:02 UTC
    If you use the -t flag you can specify the header in the body.
    open (MAIL,"|sendmail -t") || die "Unable to open sendmail"; print MAIL "To: $recipient\n"; print MAIL "From: $friendly_email\n"; print MAIL "Reply-to: $reply_email\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$body"; close (MAIL) || die "Unable to send e-mail";
Re: Perl-based Newsletter Script Needs Your Help
by davorg (Chancellor) on Jul 13, 2000 at 14:14 UTC

    If you were using the Mail::Mailer or Mail::Send then you could use their options to set the mail headers. CPAN also has a Mail::Bulkmail module which would seem to be tailored to make your job a lot easier.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>
Re: Perl-based Newsletter Script Needs Your Help
by ikitat (Acolyte) on Jul 13, 2000 at 17:35 UTC
    you may also want to check out the genericstable / masquerade_envelope features for sendmail. the genericstable is pretty simple..
    uglyusername pretty@yellowflowers.org
Re: Perl-based Newsletter Script Needs Your Help
by Michalis (Pilgrim) on Jul 14, 2000 at 01:18 UTC
    May I suggest MIME::Lite? I'm using it for sending several mails and it can definitely do what you want it to. It can also send attachments, so in case you want to send images or binary files someday you won't have to rewrite your script again.
Re: Perl-based Newsletter Script Needs Your Help
by nickcave25 (Acolyte) on Jul 14, 2000 at 15:29 UTC
    Michalis, ikitat, c-era, davorg, and le:
    Thanks for the suggestions. I will hopefully get a chance to test some of them out this weekend. And I will post an update once I get something to work.

    I actually have a followup question which some of you and others might be interested in addressing, but I will need to work on setting up a simplest case version of that section of the code to keep it simple (and real).

    I should probably post the whole thing on my website once I get it working and beat it into some kind of respectable shape so that someone else with a similar need can have at it. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://22342]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found