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

Dear Monks:
sub sendmail { my $server = 'emailserver.com'; my $from = 'myemail@emailserver.com'; my $disguise = 'mygmail@gmail.com'; my $to = $_[0]; my $subject = $_[1]; my $body = $_[2]; use MIME::Lite; my $msg; $msg = MIME::Lite -> new( From => $from, To => $to, CC => $from, Subject => $subject, Type => 'text/html', Data => qq{$body} ); if(not $msg ->send('smtp', $server, Timeout => 60, Debug => 1)){ die "Can not send the message.\n"; } }
How can I disguise the sender's email address with MIME::Lite?

I am trying to let the email recipient see my mygmail@gmail.com as the sender' address instead of the myemail@emailserver.com who sends the email. I have to use myemail@emailserver.com in the "From" because the emailserver.com requires the sender's email must be in the server's private list.

I know I can disguise it using Net::SMTP easily, but Net::SMTP does not support html email as far as I know.

Disclaimer: I'm not trying to spam anybody using email. I just need to use this function so that recipient can reply to the right email address.

Any help will be appreciated!

Replies are listed 'Best First'.
Re: How to disguise sender's email address with MIME::Lite?
by bobf (Monsignor) on Jun 12, 2007 at 02:49 UTC

    I just need to use this function so that recipient can reply to the right email address.
    It sounds like the 'reply-to' field will meet your needs (see the RFC 2822 email standard). 'reply-to' is supported by MIME::Lite, and using it won't require you to disguise the sender's address.

    HTH

Re: How to disguise sender's email address with MIME::Lite?
by clinton (Priest) on Jun 12, 2007 at 13:43 UTC
    Will this do the trick? From the MIME::Lite docs:
    FromSender

    If defined, this is identical to setting SetSender to true, except that instead of looking at the "From:" field we use the address given by this option. Thus:

    FromSender => 'me@myhost.com'
    Clint
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: How to disguise sender's email address with MIME::Lite?
by sago (Scribe) on Jun 12, 2007 at 08:28 UTC


    #!/bin/perl
    use MIME::Lite;
    MIME::Lite->send('smtp', "emailserver.com", Timeout=>90);
    my $Subject = "This email was generated automatically.\n";
    my $MailFrom = "mygmail@gmail.com ";
    my $to_list = 'john.kinney@gmail.com,jboss.s@gmail.com';
    my $cc_list = 'vid.coll@gmail.com';
    $msg = MIME::Lite->new(
    From => $MailFrom,
    To => $to_list,
    Cc => $cc_list,
    Bcc => $bcc_list,
    Subject => $subject,
    Type => 'TEXT',
    Encoding=> '7bit',
    Data => $a
    );
    $msg->send()
    }
      Thanks for your input. But my problem is that the $MailFrom has to be myemail@emailserver.com for the email to be sent out using emailserver.com.