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

Hi Monks, I am using a small perlscript to send some plain text email to some groupmembers. Everything is working fine except the subject. There is no errormessage whatsoever, but still the subject appears as textline (including the parameter's name "Subject: " in the emails body ... Any ideas ?
open (MAIL,"|$mailprog"); print MAIL "From: $wer\n"; print MAIL "To: $liste[$empf]\n"; print MAIL "Subject: $betreff"; # print MAIL "Subject: Kruzifünfe !\n"; # print MAIL "Bcc:$empfenger[$empf]\n"; # print MAIL "-" x 75 . "\n\n"; print MAIL "\n\n"; print MAIL $text; # print MAIL "-" x 75 . "\n"; #print "Index".$empf; close (MAIL);

Replies are listed 'Best First'.
Re: Sendmail doesn't send subject
by Corion (Patriarch) on Sep 12, 2016 at 17:50 UTC

    Please use MIME::Lite or something else instead of piping to sendmail.

    Most likely, $wer or $liste[$empf] contains a newline which makes sendmail think that the headers have ended. Where/how do you fill these variables? If they are user submitted or come from outside your program, please consider that this will be used by spammers to send mail through your server to others.

Re: Sendmail doesn't send subject
by neilwatson (Priest) on Sep 12, 2016 at 17:53 UTC

    consult Kensho for a list of well loved email modules to make your life simpler.

    Neil Watson
    watson-wilson.ca

      Hi Neil, thanks a lot for your quick reply ! I came across the risk that sendmail brings along on my search for a solution. I'll take your advice and alter the method/module. Yet you might be intersted in the fact that you were guessing right : It was a newlind at the end of the receipients variable. Kind regards Ulrich Herbertz