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
This is configuration of my PHP at Php.ini:
[mail function]
SMTP = smtp.gmail.com
smtp_port = 465
mail.add_x_header = Off
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 />
<!--
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>");
}
}
?>