Search code examples
perlemailsendmailmimehtml-entities

How is it possible to use a special character (a star) in the "from" field using Perl's sendmail


I am using Perl's SENDMAIL to receive email from my website:

open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
    print SENDMAIL "From: $from\n";
    print SENDMAIL "Subject: $subject\n";
    print SENDMAIL "To: $to\n";
    print SENDMAIL "Content-type: text/plain\n\n";
    print SENDMAIL $message;
close(SENDMAIL);

And I would like to modify the $from variable to be something like this:

$from = "&#x2605; David Jones <david.jones@oozicle.com>"

What happens right now is that I just see the ampersand etc., and the star is not shown.

I know that it is possible to use special characters because I receive spam containing them.

Is it possible to do this using SENDMAIL?


Solution

  • use Encode qw( encode );
    
    my $name = "\x{2605} David Jones";
    my $addr = 'david.jones@oozicle.com';
    
    my $from_header = encode('MIME-Header', $name) . ' <' . $addr . '>';