View Full Version : Creating mail object using Mail::factory ("smtp", ....) and FormMail

13-Jul-2004, 07:10 PM
My domain host has changed its pHp mail handling to use an SMTP server - see below.

I was hoping to use FormMail, but note that is does not (I think) suppor tthis configuration. Is there a permitted modification to the function SendCheckedMail() that I can use - if so, can anybody help, and are we permitted to modify the script??

In hopeful anticipation



$recipients = "mail_to@domain.mail";

$headers["From"] = "mail_from@domain.mail";
$headers["To"] = "mail_to@domain.mail";
$headers["Subject"] = "Test message";

$body = "TEST MESSAGE!!!";

$params["host"] = "";
$params["port"] = "25";
$params["auth"] = false;
$params["username"] = "user";
$params["password"] = "password";

// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);

$mail_object->send($recipients, $headers, $body);

13-Jul-2004, 10:27 PM

Yes, you're welcome to modify our FormMail to suit your needs (but please note the conditions listed at the top of the file regarding modification and distribution).

However, if you do modify it then it will make it much harder for you to upgrade to later versions.

Your hosting provider has asked you to use a PEAR module. Since this is becoming a standard feature of PHP, we're happy to add this as an option to FormMail.

This means you'll be able to enable it with a simple configuration option and future upgrading will be easy (esp. through the Upgrade Wizard).