使用php和梨在Windows上发送邮件 [英] sending mail using php and pear on windows
问题描述
require_onceMail.php;
$ from =onlinebookstorb@gmail.com;
$ to ='$ email';
$ subject =网上书店信息;
$ body =这是您的Id'$ userID'点击< a href = .. / index.php>这里< / a>更改为去网站; // 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'=> $ host,
'port'=> $ port,
'auth'=>
'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>);
}
这是我得到的错误:
严格标准:非静态方法Mail :: factory()不应静态调用C:\xampp\htdocs\OnlineBookStore\Store\第85行的Register.php
严格标准:非静态方法PEAR :: isError()不应静态调用,假设$ C来自不兼容的上下文C: \\ xampp\php\PEAR\Mail\smtp.php在线365
严格标准:非静态方法PEAR :: isError()不应该称为静态的,假设$这是来自不符合上下文的C:\xampp\php\PEAR\Net\SMTP.php第450行
严格标准:非静态方法PEAR :: isError()不应该静态调用,假设$ this来自不符合上下文的C:\xampp\php\PEAR\Net\SMTP.php第467行
我遇到同样的问题,并使用以下方式解决:
@require_onceMail.php;
...
$ 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)){
请注意,一个 @
到所有的梨/邮件呼叫。
我更喜欢这个解决方案来更改一般的错误消息设置,因为我不想看到梨/邮件警告,但我想看到适用于我自己的代码的那些。
I am trying to send an e-mail using php script but i am getting errors this is my code.i am using xampp netbeans and windows. and i included pear in the php.ini file but still having thies errors any ideas
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' => $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>");
}
and this is the errors i am getting :
Strict Standards: Non-static method Mail::factory() should not be called statically in C:\xampp\htdocs\OnlineBookStore\Store\Register.php on line 85
Strict Standards: Non-static method PEAR::isError() should not be called statically, assuming $this from incompatible context in C:\xampp\php\PEAR\Mail\smtp.php on line 365
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 450
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 467
I just ran into the same problem and solved it using:
@require_once "Mail.php";
...
$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)) {
Notice that I prepended an @
to all pear / mail calls.
I prefer this solution to changing the general error message settings as I don't want to see the pear / mail warnings but I do want to see the ones that apply to my own code.
这篇关于使用php和梨在Windows上发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!