http://qs321.pair.com?node_id=40401

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

I have a script using Mail::Mailer module for Perl and when ever I send mail using it, I only pass one word to the "From" variable, yet when the mail comes back it gets an @firewall-mydomain.com appended to it. Eg.) from = testing and when I get the mail back it has From: testing@firewall-mydomain.com Should I put a switch of some type on the ("sendmail") portion of this script?
{ use Mail::Mailer; use strict; my ($to, $from, $subject, $body) = ( @_); my $mailer = Mail::Mailer->new("sendmail"); $mailer->open({ From => $from, To => $to, Subject => $subject, }); print $mailer $body; $mailer->close();

Replies are listed 'Best First'.
Re: Mail::Mailer
by kilinrax (Deacon) on Nov 07, 2000 at 23:48 UTC
    That's not a bug, it's a feature ;-)
    Your MTA will automatically append the local domain to any email addresses that do not specify a domain.
    You may well be able to configure sendmail not to do this, but I don't know how.
    To the best of my knowledge, you can't pass flags to sendmail using Mail::Mailer.
Re: Mail::Mailer
by extremely (Priest) on Nov 08, 2000 at 07:41 UTC
    You should put a real address there. =) If the word is real important, try making up an address with name and letting the important word (e.g. testing) be the "name" of the user. Make your MTA happy and your MTA will still drive you nuts... but at least you'll be doing it correctly!
    $mailer->open({ From => "$from <root\@place.dom>", To => $to, Subject => $subject, }); ## or $mailer->open({ From => "$from <$from\@place.dom>", To => $to, Subject => $subject, });

    --
    $you = new YOU;
    honk() if $you->love(perl)

RE: Mail::Mailer
by mitd (Curate) on Nov 08, 2000 at 03:13 UTC
    You could try using sendmail's '-f' switch, but here read this quote from the sendmail manpage.

    <quote> -f name
    Sets the name of the ``from'' person (i.e., the sender of the ail). -f can only be used by ``trusted'' users (normally root, daemon, and network) or if the person you are trying to become is the same as the person you are. </quote>

    mitd-Made in the Dark
    'My favourite colour appears to be grey.'