像DISCUZ那样,在虚拟主机都能发邮件
怎么弄?
和通过SMTP发邮件有区别吗?

解决方案 »

  1.   

    http://www.phpe.net/articles/225.shtml
      

  2.   

    虚拟主机由很多自定义函数都不支持,我是用mail发邮件关注ing
      

  3.   

    建议你下载下wordpress,然后看看wp_mail.php文件就知道了
    Shenzhen Travel
      

  4.   

    自己的搞定了,用phpmailer做的
    实现代码大致如下:
    <?php//error_reporting(E_ALL);
    error_reporting(E_STRICT);date_default_timezone_set('America/Toronto');require_once("class.phpmailer.php");
     // optional, gets called from within class.phpmailer.php if not already loaded
    require_once("class.smtp.php");$mail             = new PHPMailer();$body             = $mail->getFile('contents.html');
    $body             = eregi_replace("[\]",'',$body);$mail->IsSMTP();
    $mail->SMTPAuth   = true;                  // enable SMTP authentication
    // sets the prefix to the servier,如果是gmail需要开启ssl并修改smtp和端口
    //$mail->SMTPSecure = "ssl";                 
    $mail->Host       = "smtp.163.com";      // sets 163 as the SMTP server
    $mail->Port       = 25;                   // set the SMTP port for the 163 server$mail->Username   = "xxxx";  // 163 username 163帐户的用户名,需要与前面的smtp对应
    $mail->Password   = "xxxx";            // 163 password 163帐户密码,与前面对应$mail->AddReplyTo("[email protected]","First Last");//回复邮箱地址,发送时没什么用。$mail->From       = "[email protected]";//发件人地址,需要更改
    $mail->FromName   = "xxx"; //发件人名称$mail->Subject    = "test";$mail->Body       = "testtesttest";                      //HTML Body,内容,
    //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; 
    // optional, comment out and test
    $mail->AltBody ="text/html";
    $mail->WordWrap   = 50; // set word wrap$mail->MsgHTML($body);$mail->AddAddress("[email protected]", "test");//收件人,需要修改//$mail->AddAttachment("images/phpmailer.gif");             // attachment$mail->IsHTML(true); // send as HTMLif(!$mail->Send()) {
      echo "Mailer Error: " . $mail->ErrorInfo;
    } else {
      echo "Message sent!";
    }?>不过目前,我收件箱收到的内容是空的,不知道为什么。