027-87227388

windows下xampp发邮件的配置方法

发布时间:2013-01-24 浏览:1196

1  php.ini

SMTP =smtp.126.com
smtp_prot =25
sendmail_from = xxxx@126.com
sendmail_path = "D:\xampp\sendmail\sendmail.exe -t"

2  D:\xampp\sendmail\sendmail.ini

smtp_server=smtp.126.com
error_logfile=error.log
debug_logfile=debug.log

auth_username=xxxx@126.com
auth_password=mailpassworld
force_sender=xxxx@126.com

<?php
$txt = "First line of text\nSecond line of text";
$txt = wordwrap($txt,70);
//$v = mail("subject",$txt);
//var_dump($v);

$from_name = "Justrealized";
$from_email = "";
$headers = "From: $from_name <$from_email>";
$body = "Hi, \nThis is a test mail from $from_name <$from_email>.";
$subject = "Test mail from Justrealized";
$to = "";

if (mail($to, $subject, $body, $headers)) {
  echo "success!";
} else {
  echo "fail…";
}

?>