PHP使用pear_smtp发送简单邮件
程序员文章站
2022-05-10 18:31:49
...
PHP使用pear_smtp发送简单邮件
<?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)!