PEAR中有现成的SMTP类
使用PHP内置的mail函数也可以,需要读取php.ini中定义的服务器信息。
最终都是通过socket出去的mail
(PHP 3, PHP 4 )mail -- send mail
Description
bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
mail() automatically mails the message specified in message to the receiver specified in to. Multiple recipients can be specified by putting a comma between each address in to. Email with attachments and special types of content can be sent using this function. This is accomplished via MIME-encoding - for more information, see this Zend article or the PEAR Mime Classes例:
<?php
mail("[email protected]", "the subject", $message,
     "From: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
    ."Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
    ."X-Mailer: PHP/" . phpversion());
?>