Showing posts with label mail. Show all posts
Showing posts with label mail. Show all posts

Sunday, March 01, 2009

Non-Ascii characters in MIME headers

Message Header Extensions for Non-ASCII Text: http://tools.ietf.org/html/rfc2047
The text is encoded in this ways:

   encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
   charset = token    ; 
   encoding = token   ; 
   token = 1*<Any CHAR except SPACE, CTLs, and especials>
   especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / "
               <"> / "/" / "[" / "]" / "?" / "." / "="
   encoded-text = 1*<Any printable ASCII character other than "?" or SPACE>

Supported encodings  include "Q"(similar to quoted-printable) and "B" (Base64).

For example,

=?gb2312?Q?[CSDN]=C2=DB=CC=B3=D3=C3=BB=A7=BC=A4=BB=EE=CD=A8=D6=AA?=
represents text "[CSDN]论坛用户激活通知".
Note: SPACE and TAB are not allowed in encoded text. SPACE must be encoded using "=20".

Saturday, July 19, 2008

Send email in PHP

On linux, a tool called sendmail can be used to send emails. You don't need a SMTP server to send emails out. An interesting thing about sendmail is that you can not set some common email fields easily. For example, you can not set email subject directly on command line by using a switch. Instead following syntax should be used:

sendmail destination@domain.com
Subject: This is the subject.
Main body goes here
.

In PHP, users can send email easily because PHP relies on sendmail. See this page for instructions. Main configuration options in php.ini:

Mail configuration options
Name Default Changeable Changelog
SMTP "localhost" PHP_INI_ALL  
smtp_port "25" PHP_INI_ALL Available since PHP 4.3.0.
sendmail_from NULL PHP_INI_ALL  
sendmail_path "/usr/sbin/sendmail -t -i" PHP_INI_SYSTEM