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

I am trying to send a mass email with an attachment using Mail::Sender. I am successful in sending the email along with the file, however I am unsuccessful in displaying from whom it is from correctly. What I get is joeshmoe@mymailhost rather than just joeshome, which is what I want. Here is my code.
my %mail; $mail{'to'} = $emails; $mail{'file'} = 'test.txt'; $mail{'subject'} = 'test'; $mail{'msg'} = "Please work"; my $sender = new Mail::Sender{ smpt=> 'mailhost', from=> 'joe@pleasework.com', fake_from => 'Joe Shmoe'}; $sender-> MailFile(\%mail);
Any help will be much appreaciated

Replies are listed 'Best First'.
Re: presentation of email
by Mr. Muskrat (Canon) on Mar 18, 2003 at 16:29 UTC

    Mail::Sender (as well as most email modules) allows you to use a name with the email address in brackets. You aren't faking an address so don't use fake_from.

    my %mail; $mail{'to'} = $emails; $mail{'file'} = 'test.txt'; $mail{'subject'} = 'test'; $mail{'msg'} = "Please work"; my $sender = new Mail::Sender{ smpt=> 'mailhost', from=> 'Joe Shmoe <joe@pleasework.com>', }; $sender-> MailFile(\%mail);

      Thanks for the quick response. I don't want the <joe@pleasework.com> to show up. Is it possible to prevent it from appearing.

        I don't want the <joe@pleasework.com> to show up.

        Basically, this is IMHO not up to you, but the recipients choice.
        A lot of mail-clients won't show the address-part if a name is given along with it, but you shouldn't try to enforce this behaviour, even if it is possible.

        regards,
        tomte


Re: presentation of email
by Jenda (Abbot) on Mar 18, 2003 at 18:32 UTC

    You are NOT spamming, are you?!?

    The code should work fine. If I try it myself I do get just the Joe Shmoe in the From: field. And the only place where I see the joe@pleasework.com is the Return-Path: header. Which is not visible in my client anywhere.

    What mailserver do you send this to, what mail client do you use to look at the result and what do the headers look like there? Could you copy the message headers as the mail client got them in here?

    Jenda

      I am not spamming...
      I am Reading the email via microsoft outlook and u see joe@pleasework.com. I am now trying to use Net:SMTP which works well in regards to hiding the address, but when I hit reply it sends the email to joe not joe@pleasework.com. If u understand why, please let me know.
      use Net::SMTP; $sender = Net::SMTP->new ('mailhost'); $sender->mail('joe@pleasework.com'); $sender->to ('bob@hotmail.com'); $sender->data(); $sender->datasend ("From: Joe\n"); $sender->datasend ("To: Bob\n"); $sender->datasend ("Subject: $mail{'subject'}\n"); $sender->datasend ("\n"); $sender->datasend ("$mail{'msg'}"); $sender->dataend; $sender->quit;

        It sends the reply to joe, because your from line says 'Joe'. You should use a complete from line, or most people will not be able to reply to you. What you want to appear isn't relevant, it is up to the receivers email client to determine which parts of the address to show.


        We're not surrounded, we're in a target-rich environment!