PEAR Mail throws numerous errors
Hi there,
I need to send an email using PHP. I started using the built in mail function, but I discovered I need SMTP authentication, so I decided to use the PEAR Mail::factory class.
I get a lot of Strict Standards errors, but the email sends. Other forums on the web suggest changing the error_reporting setting in php.ini to E_ALL ^ E_STRICT, to remove the errors. I have done that, but the errors remain. (Besides I'm not overly happy about "hiding" errors. Presumably they are there for a reason.)
Here's the script:
PHP Code:
<?php
include("Mail.php");
/* mail setup recipients, subject etc */
$recipients = "example@example.com";
$headers["From"] = "example@somewhere.com";
$headers["To"] = "example@example.com";
$headers["Subject"] = "Test";
$mailmsg = "Hello, This is a test.";
/* SMTP server name, port, user/passwd */
$smtpinfo["host"] = "smtp.example.com";
$smtpinfo["port"] = "25";
$smtpinfo["auth"] = true;
$smtpinfo["username"] = "username";
$smtpinfo["password"] = "password";
/* Create the mail object using the Mail::factory method */
$mail_object = Mail::factory("smtp", $smtpinfo);
/* Ok send mail */
$mail_object->send($recipients, $headers, $mailmsg);
?>
The first error message I get is:
Strict Standards: Non-static method Mail::factory() should not be called statically in ... on line ...
most of them refer to methods being called statically. I have no idea what that means, except the opposite of dynamically...
Any help is greatly appreciated,
Mike