其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
PHP PEAR MAIL发送TEXT/HTML格式邮件

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

一 TEXT格式
邮件发送方式有3种
* mail
    If safe mode is disabled, $params will be passed as the fifth argument to the PHP mail()
    function. If $params is an array, its elements will be joined as a space-delimited string.
* sendmail
    $params["sendmail_path"] - The location of the sendmail program on the filesystem.
    Default is /usr/bin/sendmail
    $params["sendmail_args"] - Additional parameters to pass to the sendmail program.
* smtp
    $params["host"] - The server to connect. Default is localhost
    $params["port"] - The port to connect. Default is 25
    $params["auth"] - Whether or not to use SMTP authentication. Default is FALSE
    $params["username"] - The username to use for SMTP authentication.
    $params["password"] - The password to use for SMTP authentication.

<?php
require_once('Mail/Mail.php');
$recipients         = '[email protected]';
$headers['From']    = '[email protected]';
$headers['To']      = '[email protected]';
$headers['Subject'] = 'Test message';

$body = 'Test message';

$params['username'] = '[email protected]';
$params['password'] = '111';
$params['auth'] = true;

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('mail', $params);

$mail_object->send($recipients, $headers, $body);
?>

二 HTML格式
 <?php
include('Mail.php');
include(
'Mail/mime.php');

$text = 'This is a Christmas email from www.omni-batteies.com.';
$html = '<html><body><h3><font color=red>This is a Christmas email from www.omni-batteies.com.</font></h3></body></html>';
$file = 'Special_Offer_For_Christmas.htm';
$crlf = "\n";
$hdrs = array(
              
'From'    => '[email protected]',
              
'To'      => 'Merry Christmas',
              
'Subject' => 'Christmas Message from www.omni-batteies.com'
              
);

$mime = new Mail_mime();

$mime->setTXTBody($text);
$mime->setHTMLBody($file, true);
$mime->addAttachment($file, 'text/html');

$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$params['host'] = 'mail.111.com';
$params['auth'] = true;
$params['username'] = '[email protected]';
$params['password'] = '111';
$recipients = array('[email protected]', '[email protected]');

$send = @$mail =& Mail::factory('smtp', $params);
$mail->send($recipients, $hdrs, $body);
if(
PEAR::isError($send)) {
    echo(
$send->getMessage());
} else {
    echo(
"send successfully");
}
show_source($_SERVER['PHP_SELF']);
?>




相关文章

相关软件