PHP使用pear_smtp发送简单邮件<?php
require_once "vendor/autoload.php";
$from = "test";
$to = "test ";
$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("
" . $mail->getMessage() . "
");} else {
echo("
Message successfully sent!
");}
?>
以上就是PHP使用pear_smtp发送简单邮件的内容,更多相关内容请关注PHP中文网(www.php.cn)!
本文原创发布php中文网,转载请注明出处,感谢您的尊重!