我有这个脚本:
require_once "Mail.php";
$from = "Stephen <username@nvrforget.com>";//Google apps domain
$to = "username@gmail.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.nvrforget.com";
$username = "username@nvrforget.com";
$password = "password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'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>");
}
Run Code Online (Sandbox Code Playgroud)
我想出了这个错误:
Non-static method …Run Code Online (Sandbox Code Playgroud) 我试图使用PHP脚本发送电子邮件,但我收到错误这是我的code.i我正在使用xampp netbeans和windows.我在php.ini文件中包含了pear但仍然有任何想法的错误
require_once "Mail.php";
$from = "onlinebookstorb@gmail.com";
$to = "'$email'";
$subject = "Online book store information";
$body = "This is your Id '$userID' click <a href =../index.php > here </a> to change to go to the website "; //todo change URL to make it work when it is online
$host = "ssl://smtp.gmail.com";
$port = "993";
$host = "smtp.gmail.com";
$username = "onlinebookstoreb@gmail.com";
$password = "";
$headers = array('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp', array('host' => …Run Code Online (Sandbox Code Playgroud)