用PHP发送电子邮件的问题 [英] problem with sending email with PHP

查看:113
本文介绍了用PHP发送电子邮件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
我的PHP邮件发送有问题.我是PHP的初学者.
我得到此结果,但我的电子邮件未发送:

Dear all,
I have a problem with my PHP mail sending. I am a beginner with PHP.
I get this result and my email does not send:

Strict Standards: Non-static method Mail::factory() should not be called statically in C:\xampp\htdocs\phptest\email.php on line 34

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



这是我在Php.ini上的PHP的配置:



This is configuration of my PHP at Php.ini:

[mail function]
SMTP = smtp.gmail.com
smtp_port = 465
mail.add_x_header = Off



这是我在email.php上的代码:



and this is my code at email.php:

<form method="post">
Gmail username: <input type="text" name="MailFrom"/><br />
Gmail password: <input type="text" name="MailPass"/><br />
Send Email To: <input type="text" name="MailTo"/><br />
Subject: <input type="text" name="MailSubject"/><br />
<!--CC: <input type="text" name="MailCC"/><br />-->
Body: <input type="text" name="MailBody"/><br />
<input type="Submit" name="submitMail" value="Submit Mail"/>
</form>

if(!empty($_POST['submitMail']))
{
    require_once "mail.php";

    $MailFrom=$_POST['MailFrom'];
    $MailPass=$_POST['MailPass'];
    $MailTo=$_POST['MailTo'];
    $MailSubject=$_POST['MailSubject'];
    //$MailCC=$_POST['MailCC'];
    $MailBody=$_POST['MailBody'];

    $MailHost = "smtp.gmail.com";
    $MailPort = "465";

    $headers = array ('From' => $MailFrom,
                      'To' => $MailTo,
                      'Subject' => $MailSubject);
    $smtp = Mail::factory('smtp',
                   array ('host' => $MailHost,
                          'port' => $MailPort,
                          'auth' => true,
                          'username' => $MailFrom,
                          'password' => $MailPass));

    $mail = $smtp->send($MailTo, $headers, $MailBody);

    if (PEAR::isError($mail))
    {
        echo("<p>" . $mail->getMessage() . "</p>");
    }
    else
    {
        echo("<p>Message successfully sent!</p>");
    }

}

?>

推荐答案

来自的不兼容上下文 365 上的C:\ xampp \ php \ PEAR \ Mail \ smtp.php中的"code-keyword"> 严格标准:假定
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


来自不兼容的上下文 in 中C:\ xampp \ php \ PEAR \ Net \ SMTP.php在 450 严格标准:假定
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


来自不兼容的上下文 in 中C:\ xampp \ php \ PEAR \ Net \ SMTP.php在 467
this from incompatible context in C:\xampp\php\PEAR\Net\SMTP.php on line 467



这是我在Php.ini上的PHP的配置:



This is configuration of my PHP at Php.ini:

[mail function]
SMTP = smtp.gmail.com
smtp_port = 465
mail.add_x_header = Off



这是我在email.php上的代码:



and this is my code at email.php:

<form method="post">
Gmail username: <input type="text" name="MailFrom"/><br />
Gmail password: <input type="text" name="MailPass"/><br />
Send Email To: <input type="text" name="MailTo"/><br />
Subject: <input type="text" name="MailSubject"/><br />
<!--CC: <input type="text" name="MailCC"/><br />-->
Body: <input type="text" name="MailBody"/><br />
<input type="Submit" name="submitMail" value="Submit Mail"/>
</form>

if(!empty(


这篇关于用PHP发送电子邮件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆