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

i have a form that generates an email that gets sent to a specified person in our organization. the form is to collect names and contact information from parents to keep in touch with their college-age kids.

this is the code that generates the mail:

open(MAIL, "|/usr/sbin/sendmail -oi -t") or die "Can't open sendmail: +$!\n"; print MAIL "From: no-reply <webmaster\@domain.org\n"; print MAIL "Reply-To: $efrom\n"; print MAIL "To: recipient\@mailserver.com\n"; print MAIL "Subject: $esubject\n\n"; print MAIL $emessage; close(MAIL) or warn "sendmail didn't close nicely";
the value of $emessage contains the value of $efrom and displays correctly as whatever was entered into the email field, but the actual header content for the "Reply-To" field has the domain of our webserver tacked to the end, so it'll look like "parent@hotmail.com.hivelocity.net" whereas $efrom = "parent@hotmail.com". this also happens if i use $efrom in the "From:" field of the email header.

any ideas how i can get the reply-to to get sent correctly? what am i doing wrong?? i've used a similar script for many of my other forms, without any difficulty...

TIA, janaki

Replies are listed 'Best First'.
Re: domain getting tacked onto email address??
by GrandFather (Saint) on Jul 26, 2006 at 22:03 UTC

    Have you tried "hard wiring" the address (print MAIL "Reply-To: parent@hotmail.com\n";)?

    If it still fails then that implies that sendmail is giving you grief. At that point you might like to investigate MIME::Lite:

    use MIME::Lite; $msg = MIME::Lite->new( From => 'no-reply <webmaster@domain.org>', Reply-To => $efrom, To => 'recipient@mailserver.com', Subject => $esubject, Data => $emessage, ); $msg->send;

    DWIM is Perl's answer to Gödel
Re: domain getting tacked onto email address??
by Hue-Bond (Priest) on Jul 26, 2006 at 21:40 UTC
    print MAIL "From: no-reply <webmaster\@domain.org\n";

    This lacks a '>' at the end, doesn't it?

    it'll look like "parent@hotmail.com.hivelocity.net" whereas $efrom = "parent@hotmail.com"

    Try using '<' and '>' again. If that doesn't work, it must be a sendmail configuration issue.

    --
    David Serrano

      oddly enough, i saw that error in the From: field, and fixed it, but that one is coming through just fine...

      my test $efrom value actually looks like this:

      $efrom = "$in{'Parent Name'} <$in{'Parent Email'}>";
      so, it does include the closing '>'

      and the resulting header includes this:

      Reply-To: parent name <parent@home.com.hivelocity.net>
Re: domain getting tacked onto email address??
by traveler (Parson) on Jul 26, 2006 at 22:02 UTC
    Try checking to ensure that there is no trailing space or other garbage at the end of $efrom. More likely, however, is that the server has sendmail configured that way. This is not unusual in virtual hosting situations, among others.

    HTH, -traveler