...

View Full Version : send mail() from PHP page with external SMTP host



fail
11-28-2010, 06:07 AM
I use XAMPP on Windows Xp. I had to try a few different scripts till I found a working one.

This script does not use set_ini() so no need to make any changes to php.ini , or any other XAMPP whatever page:




<?php

include("Mail.php"); // Mail.php is integrated in php and not a separate file

$recipients = "receiver@domain.com";

$headers["From"] = "me@sender.com";
$headers["To"] = "receiver@domain.com";
$headers["Subject"] = "Test message";

$body = "TEST MESSAGE!!!";

$params["host"] = "smtp.yourISP.com";
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = "YourLogin@yourISP.com";
$params["password"] = "YourPassword";

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

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

?>



Mail.php is an internal php function, no need to have that file in the directory.

Source: http://www.php.net/manual/en/function.mail.php#39305

pigpen
11-29-2010, 02:28 AM
Was there a question here?

Or was this suppose to go in the PHP snippets sub-forum? If so, thanks for posting the code.

coststorage
11-29-2010, 06:46 AM
Good script but also have the same question as pigpen was their a question here?

closets Seattle (http://www.amazingspaces.biz/services/custom-closets-2/)
custom closet organizers (http://www.amazingspaces.biz/services/custom-closets-2/)
seattle closet organizers (http://www.amazingspaces.biz/services/custom-closets-2/)

Dormilich
11-29-2010, 06:49 AM
Mail.php is an internal php function, no need to have that file in the directory.

Source: http://www.php.net/manual/en/function.mail.php#39305
correction: Mail.php is not an internal function (built-in), it is a PEAR package.

PS. this snippet was done by Roberto Silva



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum