其實不用改php.ini那麼麻煩,使用pear的class 就到處可以用了,還有認證的功能喔!
以下程式碼從php docs 擷取出來的!希望不會冒犯到作者!
參考網頁:http://tw2.php.net/mail
<?
include("Mail.php");
$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"] = "smtp.server";
$params["port"] = "25";
$params["auth"] = true;
$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);
?>