<?php
@require_once"Mail.php";
$from="from email"; //enter email of sender
$to="recepient email"; //enter to email
$subject="subject";
$body="content";
$host="ssl://smtp.gmail.com";
$port="465";
$username="your gmail account user name";
$pwd="your gmail account password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$headers["Content-Type"] = 'text/html; charset=UTF-8';
$smtp = @Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $pwd));
//Send Email using pear sned option
$mail = @$smtp->send($to, $headers, $body);
//If any errors occurs
if (@PEAR::isError($mail)) {
("<p>" . $mail->getMessage() . "</p>");
}
else {
echo("<p>Message successfully sent!</p>");
}
?>
添加@reduce一些错误但仍然有三个错误即将到来,它们是:
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\pear\Net\SMTP.php on line 491
严格标准:不应静态调用非静态方法 PEAR::isError(),假设 $this 来自第 265 行 C:\xampp\php\pear\Net\SMTP.php 中的不兼容上下文
严格标准:不应静态调用非静态方法 PEAR::raiseError(),假设 $this 来自第 267 行 C:\xampp\php\pear\Net\SMTP.php 中的不兼容上下文