Download Deploying DNS and Sendmail
Transcript
Getting the Return Address # Try to get return address from envelope From. # Quit silently if message is from MAILER-DAEMON. # Complain bitterly if we detect shell metachars. # $header[0] = <STDIN>; ($from) = $header[0] =~ /^From\s+(\S+)/; exit(0) if (!length($from) || $from eq '<>' || $from =~ /mailer-daemon/i); die "Hostile address: $from\n" if ($from =~ /[\\|&;]/); All SMTP-style email messages begin with a line that looks like From <address> <date> This is generally referred to as the envelope From header to distinguish it from the From: header that appears elsewhere in the message. Lesson #1 is that the envelope From header is the only address header you should believe. Don't use any addresses from elsewhere in the message because they might be forgeries or unintentional lies. Lesson #2 is that the envelope From can also be forged and people can do nasty, nasty things to you if you're not very careful (like embedding rm -rf commands in mail addresses). Note that we look for dangerous shell metacharacters before proceeding. Lesson #3 is that you should never respond to messages from the user MAILERDAEMON (aka user <>). These are always auto-generated messages. 143