Q&A > mail and news > How do you properly use sendmail? - Answer contributed by Juerd

my $mailer = '/usr/sbin/sendmail -t -oi'; my $recipient = ''; my $message = '...'; open my $mailer, "|$mailer" or die $!; print $mailer <<"END" or die $!; From: user\ To: $recipient Subject: Testing 123 $message END close $mailer or die $!;
Remember to make sure all data that goes into the headers (just $recipient in this example) is valid.