稳定经得住考验的smtp发送邮件的类(请付上使用方法),万分感谢

WBOY
发布: 2016-06-13 13:51:54
原创
1293 人浏览过

求一个稳定经得住考验的smtp发送邮件的类(请付上使用方法),万分感谢!
我找了几个,有的不能用,发不出,有的居然没有正文;
还有一个正文这些都有,但没发几封就说 "帐号已经被锁定 ",discuz\phpwind这些的邮件类又搞得太复杂,剥离不出来!

谢谢拉!!!
用mail函数和iis得smtp,它又老是说address   invalid!怎么改地址都不行: "aaa "   or   "aaa@163.com ",都是错得

如果比较大,lein_urg@163.com,请发到邮箱,谢谢!
发邮件者20分起哈,如果正确得话60分起!

------解决方案--------------------
class smtp
{
/* Public Variables */
var $smtp_port;
var $time_out;
var $host_name;
var $log_file;
var $relay_host;
var $debug;
var $auth;
var $user;
var $pass;

/* Private Variables */
var $sock;

/* Constractor */
function smtp($relay_host = " ", $smtp_port = 25,$auth = false,$user,$pass)
{
$this-> debug = FALSE;
$this-> smtp_port = $smtp_port;
$this-> relay_host = $relay_host;
$this-> time_out = 30; //is used in fsockopen()
$this-> auth = $auth;//auth
$this-> user = $user;
$this-> pass = $pass;
$this-> host_name = "localhost "; //is used in HELO command
$this-> log_file = " ";
$this-> sock = FALSE;
}

/* Main Function */
function sendmail($to, $from, $subject = " ", $body = " ", $mailtype, $cc = " ", $bcc = " ", $additional_headers = " ")
{
$mail_from = $this-> get_address($this-> strip_comment($from));
$body = ereg_replace( "(^|(\r\n))(\.) ", "\1.\3 ", $body);
$header .= "MIME-Version:1.0\r\n ";
if($mailtype== "HTML ")
{
$header .= "Content-Type:text/html\r\n ";
}
$header .= "To: ".$to. "\r\n ";
if ($cc != " ")
{
$header .= "Cc: ".$cc. "\r\n ";
}
$header .= "From: $from \r\n ";
$header .= "Subject: ".$subject. "\r\n ";
$header .= $additional_headers;
$header .= "Date: ".date( "r "). "\r\n ";
$header .= "X-Mailer:By Redhat (PHP/ ".phpversion(). ")\r\n ";
list($msec, $sec) = explode( " ", microtime());
$header .= "Message-ID: \r\n ";
$TO = explode( ", ", $this-> strip_comment($to));

if ($cc != " ")
{
$TO = array_merge($TO, explode( ", ", $this-> strip_comment($cc)));
}
if ($bcc != " ")
{
$TO = array_merge($TO, explode( ", ", $this-> strip_comment($bcc)));
}
$sent = TRUE;
foreach ($TO as $rcpt_to)
{
$rcpt_to = $this-> get_address($rcpt_to);
if (!$this-> smtp_sockopen($rcpt_to))
{
$this-> log_write( "Error: Cannot send email to ".$rcpt_to. "\n ");
$sent = FALSE;
continue;
}
if ($this-> smtp_send($this-> host_name, $mail_from, $rcpt_to, $header, $body))
{
$this-> log_write( "E-mail has been sent to \n ");
}
else
{
$this-> log_write( "Error: Cannot send email to \n ");
$sent = FALSE;
}
fclose($this-> sock);
$this-> log_write( "Disconnected from remote host\n ");
}
return $sent;

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!