<?php require_once "vendor/autoload.php"; $from = "test<test@163.com>"; $to = "test <test@outlook.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "smtp.163.com"; $port = "25"; $username = "test@163.com"; $password = "test123"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, // 'debug'=>true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?>
以上就是PHP使用pear_smtp发送简单邮件的内容,更多相关内容请关注PHP中文网(www.php.cn)!