#assuming email_address was declared and currently has no escapes #print "from is $from_string\n"; $email_address =~ s/@/\@/; $from_string =~ s/@/\@/; open( SENDMAIL, "|/usr/lib/sendmail -oi -t" ) or die "Can't fork for sendmail: $!\n"; print SENDMAIL <<"EOF"; From: $from_string To: $email_address Subject: $subject Content-type: text/html $$textref EOF close(SENDMAIL) or warn "sendmail didn't close nicely"; print qq ( email sent to $email_address\n);