php使用Pear的NetMail发送smtp邮件
时间:2021-07-01 10:21:17
帮助过:4人阅读
$params = array('host' => 'localhost', - 'port' => '25',
- 'username' => 'test@jbxue.com',
- 'password' => 'test');
//$to = $test_mail; - $recipients = $to; 接收人,可以是一个数组来存放多个地址
$headers['From'] = $email; - $headers['To'] = $to;
- $headers['Subject'] = $subject;
$body = $message; - //选择smtp的发送方式,当然还支持mail()和sendmail
- $mail_object = &Mail::factory('smtp', $params);
- if (PEAR::isError($e = $mail_object->send($recipients, $headers, $body))) {
- die($e->getMessage() . "\n");
- }
- ?>
|