perl-noobie has asked for the wisdom of the Perl Monks concerning the following question:

Noobie question: trying to configure .pl script in formmail.pl to add the senders realname in the message header of an email after post method. The html form can be found here: http://www.superchute.com/new/Chutes/chute_quote.html As you can see in the html source code, the name field has the input name 'realname'. I am getting 'Unknown sender' in our emails. The .pl script is viewable here: http://www.superchute.com/FormMail.txt Thanks.

Replies are listed 'Best First'.
Re: perl formmail question
by ww (Archbishop) on Aug 26, 2015 at 18:49 UTC

    Better yet, use the version provided by London Perl Mongers: nms formmail which is vastly improved and more secure than your version. What's more, nms formail is more recently updated... and (based on comparative reputations) far less likely to introduce a bug or security gap in whatever you're using it for.

    For future reference (and welcome, BTW, to PM!), I didn't chase either address you gave because

    1. I'm busy and they're not links as they would have been had you enclosed them in square brackets, per Markup in the Monastery, What shortcuts can I use for linking to other information? and/or Perl Monks Approved HTML tags
            ...and
    2. Fixing what's already been fixed very well is a waste (in the form of re-inventing a wheel)
            ...and
    3. I already know they're far too long to waste time on (i.e., they are TL, DR material). See On asking for help, How do I post a question effectively? and Writeup Formatting Tips.
    Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
    1. code
    2. verbatim error and/or warning messages
    3. a coherent explanation of what "doesn't work actually means.
Re: perl formmail question
by stevieb (Canon) on Aug 26, 2015 at 15:18 UTC

    formmail.pl has had significant security issues dating back to the first days of email spam. Unless there's been magic done to it in recent years, I'd recommend researching another solution and steering very clear of it.

    Your version is exceptionally old. This version is more recent, but I still wouldn't personally use it and unless otherwise convinced, will attempt to convince others not to as well.

Re: perl formmail question
by 1nickt (Canon) on Aug 26, 2015 at 16:56 UTC

    I agree with stevieb. "Matt's Script Archive" was known as a pile of junk in 1995 when he started it. His versions of tools enabled people with (a) no programming ability and (b) no access to their server, to do something like what you are attempting, e.g. send an email through a form -- as long as you didn't care about security, or memory leaks, or the thing actually working all the time.

    You should hire a Perl programmer and pay him or her to go into your server and redo your script with proper tools. Even the most unenlightened shared hosting company nowadays will have the necessary CPAN modules, such as MIME::Lite for example. Really, truly you should do this. It's an hour or two's work for anyone who knows what they are doing.

    I see that you describe yourself as a "noobie" so maybe you would like to learn Perl: start by finding out what Perl modules your host server provides, and what is the procedure for installing them. If you are on a server using cPanel it should be just some buttons to click. When you have installed a module (or two) so that you can safely send emails using such tools, you can substitute your own script instead of the one you have, and you'll be able to use your same HTML page with the same form fields, so you don't have to worry about having to change the website. And then you'll be doing it right.

    In the mean time, not that you should do this, because you should do what I suggested above, but try changing:

    print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
    to:
    print MAIL "From: $Config{'realname'} <$Config{'email'}>\n";
    The way forward always starts with a minimal test.

      I have some scripts using MIME::Lite out there but I don't recommend it to people and I need to update to use something else.

      From the MIME::Lite docs:

      WAIT!

      MIME::Lite is not recommended by its current maintainer. There are a number of alternatives, like Email::MIME or MIME::Entity and Email::Sender, which you should probably use instead. MIME::Lite continues to accrue weird bug reports, and it is not receiving a large amount of refactoring due to the availability of better alternatives. Please consider using something else.

        I'm familiar with that notice. I'm pretty sure that RJBS means that other alternatives are "better" and he is not really interested in spending time on bug reports etc from something he feels is sub-optimal. Fair enough, buyer beware, but I am happy with it.

        I have not experienced any problems with MIME::Lite, but then I use it for trivial e-mailing (no attachments, ASCII-only subject line, etc). In particular I continue using it because it is installed on most shared hosting servers, and since MIME::Lite::TT is Pure Perl, a user can install that in his/her home directory and run it with no compiler needed. For distributing programs to customers this combo is great, since they can be handed a Template template, and a Config::Tiny config file, with which they can completely control the email messaging, while keeping their fingers out of the code.

        The way forward always starts with a minimal test.