100分问个PHP用SMTP发邮件的解决方案 PHP 的SMTP类已经很多、很成熟了。 建议你有时间GOOGLE一下~~~~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 再详细一点吧:$target="[email protected]"//发送目标$title="title of the mail";//标题$content="******"//邮件正文SMTP服务器是要权限验证的,我看了一下php.ini中有SMTP="localhost"一句,还有个for Win32 only之类的,不知道linux下该怎么弄 SMTP的类,一般都是用 Socket 直接连接 SMTP 服务器,按照SMTP协议进行发送EMAIL的。建议看看别人的源码及SMTP 协议的内容,你就会明白了~~ Linux下和windows下发邮件有些不同吧,php.ini里的一些内容:[mail function]SMTP = localhost ;仅用于win32系统sendmail_from = [email protected] ;仅用于win32系统;sendmail_path = ;仅用于unix, 也可支持参数(默认的是'sendmail -t -i') 如果你的服务器支持PEAR,那就用这个吧<?php/*Project Name: PublicClslibClass Name: SmtpMailFile Name: SmtpMail.cls.phpDescription: 利用PEAR的Smtp发送邮件类Author: Walter LiuCreate time: 2004-09-25version: 1.0.0==========================================================================================@==========================================================================================*/require_once 'Mail.php'; class SmtpMail{ /** * 服务器名称 * * @var string */ var $__host = "localhost"; /** * true表示smtp服务器需要验证,false代码不需要 * * @var bool */ var $__auth = true; /** * 用户名 * * @var string */ var $__username = ""; /** * 密码 * * @var string */ var $__password = ""; /** * 配置数组 * * @var string */ var $__conf; /** * 邮件头数组 * * @var string */ var $__header; function SmtpMail($host = null , $username = null, $password = null) { $this->__host = $host != null ? $host : $this->__host; $this->__username = $username != null ? $username : $this->__username; $this->__password = $password != null ? $password : $this->__password; $this->__conf['mail'] = array( 'host' => $this->__host, 'auth' => $this->__auth, 'username' => $this->__username, 'password' => $this->__password ); } function send($to, $from, $subject, $body, $type = 'html') { $this->__header['type'] = $type; $this->__header['From'] = $from; $this->__header['To'] = $to; $this->__header['Subject'] = $subject; $mailObject = &Mail::factory('smtp', $this->__conf['mail']); $mail_res = $mailObject->send($this->__header['To'], $this->__header, $body); //发送 if( Mail::isError($mail_res) ){ //检测错误 die($mail_res->getMessage()); } } }?> 有个phpmailer的smtp类,你可以下载参考一下.它支持HTML,附件等... http://blog.csdn.net/czcty/archive/2005/01/25/267020.aspx 数据库出现DB connect error错误 如何在页面中加入javascript代码,实现alert窗口提示 如何使用PHP导出MSN用户好友数据 请问move_uploaded_file,第二个参数是 public://xxx/xx.xx,是怎么回事呀? 新手 请问PHP 读取 ORACLE CLOB 数据,并显示空格 关于 url rewrite 和静态页面的问题 CSDN PHP Fans 讨论群:164960 Mysql 查询最大一条记录 这个循环应该怎样写呢100分求助! 哪位高人帮忙把以此JAVA程序改成PHP,谢谢! php 写短信平台 的报价最底是多少 exec函数的使用
$title="title of the mail";//标题
$content="******"//邮件正文SMTP服务器是要权限验证的,我看了一下php.ini中有SMTP="localhost"一句,还有个for Win32 only之类的,不知道linux下该怎么弄
建议看看别人的源码及SMTP 协议的内容,你就会明白了~~
SMTP = localhost ;仅用于win32系统
sendmail_from = [email protected] ;仅用于win32系统
;sendmail_path = ;仅用于unix, 也可支持参数(默认的是'sendmail -t -i')
/*
Project Name: PublicClslib
Class Name: SmtpMail
File Name: SmtpMail.cls.php
Description: 利用PEAR的Smtp发送邮件类Author: Walter Liu
Create time: 2004-09-25
version: 1.0.0
==========================================================================================
@
==========================================================================================
*/
require_once 'Mail.php'; class SmtpMail
{
/**
* 服务器名称
*
* @var string
*/
var $__host = "localhost";
/**
* true表示smtp服务器需要验证,false代码不需要
*
* @var bool
*/
var $__auth = true;
/**
* 用户名
*
* @var string
*/
var $__username = "";
/**
* 密码
*
* @var string
*/
var $__password = "";
/**
* 配置数组
*
* @var string
*/
var $__conf;
/**
* 邮件头数组
*
* @var string
*/
var $__header;
function SmtpMail($host = null , $username = null, $password = null)
{
$this->__host = $host != null ? $host : $this->__host;
$this->__username = $username != null ? $username : $this->__username;
$this->__password = $password != null ? $password : $this->__password;
$this->__conf['mail'] = array(
'host' => $this->__host,
'auth' => $this->__auth,
'username' => $this->__username,
'password' => $this->__password
);
}
function send($to, $from, $subject, $body, $type = 'html')
{
$this->__header['type'] = $type;
$this->__header['From'] = $from;
$this->__header['To'] = $to;
$this->__header['Subject'] = $subject;
$mailObject = &Mail::factory('smtp', $this->__conf['mail']);
$mail_res = $mailObject->send($this->__header['To'], $this->__header, $body); //发送
if( Mail::isError($mail_res) ){ //检测错误
die($mail_res->getMessage());
}
}
}
?>