$socket_options=数组('sl'=>数组('verify_peer_name'=>false)); $smtp=新的Net_smtp($host、null、null,false、0、$socket_options);
if(PEAR::isError($error=$smtp->connect())){ die($error->getMessage()); }
$smtp=新的Net_smtp(' ssl://mail.example.com ', 465);
$smtp->data($fp,“主题:我的主题”);
需要“Net_SMTP.php”; 类Net_SMTP_custom扩展Net_SMTP { 函数quotedata($data) { /*执行自定义数据引用*/ } }
$smtp->setDebug(true);
函数debugHandler($smtp,$message) { echo“[$smtp->host]$message\n”; } $smtp->setDebug(true,“debugHandler”);
需要“Net/SMTP.php”; $host='mail.example.com'; $from=' user@example.com '; $rcpt=数组(' 收件人1@example.com ', ' 收件人2@example.com '); $subj=“主题:测试消息\n”; $body=“正文行1\n正文行2”; /*创建新的Net_SMTP对象*/ if(!($smtp=新Net_smtp($host)){ die(“无法实例化Net_SMTP对象”); } /*连接到SMTP服务器*/ if(PEAR::isError($e=$smtp->connect())){ die($e->getMessage()。 “\n”); } /*发送“MAIL FROM:”SMTP命令*/ if(PEAR::isError($smtp->mailFrom($from)){ die(“无法将发送器设置为<$from>\n”); } /*将邮件发送给每个收件人*/ foreach($rcpt作为$to){ if(PEAR::isError($res=$smtp->rcptTo($to)){ die(“无法将收件人<$添加到>:”.$res->getMessage()。 “\n”); } } /*设置消息正文*/ if(PEAR::isError($smtp->data($sub.“\r\n”.$body)){ die(“无法发送数据”); } /*断开与SMTP服务器的连接*/ $smtp->disconnect();