php使用gmail发邮件
php使用gmail发邮件 php使用gmail发邮件的代码片段:```phplt;?php require_once quot;Mail.phpquot;; $from = quot;lt;from.gmail.comgt;quot;; $to = quot;lt;to.yahoo.comgt;quot;; $subject = quot;Hi!quot;; $body = quot;Hi,\n\nHo
php使用gmail发邮件的代码片段:
<?php require_once "Mail.php"; $from = "<from.gmail.com>"; $to = "<to.yahoo.com>"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; $host = "ssl://smtp.gmail.com"; $port = "465"; $username = "myaccount@gmail.com"; //<> give errors $password = "password"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => 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>"); } ?> <!-- end of php tag-->
精彩图集
精彩文章