Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The ubiquitous "sendmail" handles UTF8 just fine. A very simple subroutine I have used to handle a specific form in Thai is presented below. (NOTE: It appears that perlmonks.org converts all UTF8 characters to HTML-entitites, even in <code></code> blocks, which is not the way I used it, so I have had to format my code in HTML style for proper readability.)

 


sub emailFormResults {
 
# Email the form results
 
open ( MAIL, "| /usr/lib/sendmail -t" );
#open ( MAIL, "| /usr/lib/sendmail", "-oi", "-t");
print MAIL "From: $sending_email_address\n";
print MAIL "To: $recipient_address\n";
print MAIL "BCC: $bcc_address\n";
print MAIL "Subject: $message_subject\n\n";
print MAIL <<END_OF_MESSAGE;
1. Personal Information / ข้อมูลส่วนตัว
* National ID / หมายเลขประจำตัว(ตามบัตรประจำตัวประชาชน): $national_id
* Title (นาย/นางสาว/นาง/ยศ): $title
* Full Name / ชื่อ-สกุล: $fullname
* Maiden Name / ชื่อ-สกุลเดิม(ถ้ามี): $maiden_name
* Birthday / วดป.เกิด: $birthday
* Current Address / ที่อยู่ปัจจุบัน บ้านเลขที่: $current_address
* Home Phone / หมายเลขโทรศัพท์บ้าน: $home_phone
* Cell Phone / มือถือ: $cell_phone
* Email: $email_address
* LINE Id: $line_id
* Facebook: $facebook
 
2. Occupational Information / ข้อมูลการประกอบอาชีพ ปัจจุบันประกอบอาชีพ: $occupation
* Position / ตำแหน่ง: $position
* Company / ชื่อ สถานที่ทำงาน: $company
* Salary / รายได้ต่อเดือน: $salary บาท
 
ฝากข้อความ: $comments
 
END_OF_MESSAGE
 
 
print MAIL "\n.\n";
close ( MAIL );
} # END SUB emailFormResults

 
Note that the form itself should be set to accept only UTF-8, and the HTML for the page should be properly set as well. I have used the following pieces successfully.


print <<HTML;
 
<html lang="th">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>ใบสมัครสมาชิก</title>
. . .
</head>
<body>
<form name="myform" id="myform" action="$0" method="post" accept-charset="UTF-8">
 
HTML
 
 

Blessings,

~Polyglot~


In reply to Re: UTF-8 Email Form by Polyglot
in thread UTF-8 Email Form by oswulf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others lurking in the Monastery: (2)
    As of 2021-01-18 00:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?