<?php function
postmail($receiver,$receiver_name,$subject_name,$smassage){require_once("lib/class.phpmailer.php");
 //include("lib/class.smtp.php"); $mail=new PHPMailer();$mail->CharSet ="UTF-8";//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
$mail->SMTPAuth   = true;                  // SMTP authentication
$mail->Host       = "smtpcom.263xmail.com"; // SMTP server
$mail->Port       = 25;                    // SMTP port $mail->Username   = "[email protected]"; // SMTP 账户名
$mail->Password   = "xxx";        // SMTP 账户密码
$mail->SetFrom('[email protected]', 'web');
$mail->Subject    = "$subject_name";
$smassage=str_replace('','&nbsp;',$smassage);
$smassage=nl2br($smassage);
 
$mail->MsgHTML("$smassage");
$mail->AddAddress("$receiver","t");//echo "test: " ;
 
 
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
} else {
echo "Message sent!";
   }
return true;
}  
?>

解决方案 »

  1.   

    在ubuntu上运行不显示错误也不显示成功。怎么回事啊
      

  2.   

    lib 目录和程序文件在一起吗?
      

  3.   

    都一起上传到ubuntu服务器上的
      

  4.   

    那你
    require_once("./lib/class.phpmailer.php");
    试试
      

  5.   

    你这只是一个 postmail 函数声明呀
    函数 postmail 在哪里调用的?
      

  6.   

    谢谢 xuzuning ,下面是调用<?phpif (isset($_POST["smassage"]) )
    {
    $smassage=$_POST["smassage"];
        $subject_name= $_POST["subject_name"];
    $receiver=$_POST["email"];
    $receiver_name=$_POST["email"];
    postmail($receiver,$receiver_name,$subject_name,$smassage);
    exit;} else
    ?><form id="form1" name="form1" method="post" action="" onsubmit="return form1_onsubmit()">
      <table width="100%" border="0" align="center" class="tableBoderForm">
        <tr>
          <td width="70" height="30">发件人</td>
          <td width="1417"><input type="text" name="UserName" value="[email protected]" />
          &nbsp;&nbsp;* 必添项</td>
        </tr>
        <tr>
          <td height="30"><p>收件人</p>      </td>
          <td><input type="text" name="email"  value="<?php echo $_GET["email"]; ?>" /></td>
        </tr>
        <tr>
          <td height="30">主题</td>
          <td><input name="subject_name" type="text" /></td>
        </tr>
         <tr>
          <td height="20">Massage:</td>
          <td><textarea name="smassage" cols="100" rows="20"></textarea></td>
        </tr>
     
        <tr>
          <td height="30">&nbsp;</td>
          <td><input type="submit" name="Submit" value="发送" />
          <input type="reset" name="Reset" value="重置" /></td>
        </tr>
      </table>
    </form>
    <div align="center"><br />
        <span class="cRed">*</span>  
    </div>
            <br />
        </dd>
    </dl>
    <br />
    </body>
    </html>
      

  7.   

    这个phpmailer在windows 和在linux下用法有什么不一样吗? 或者ubuntu要装什么特别的东西啊
      

  8.   

    你这个表单页里面也没有引入 postmail 函数定义的文件呀phpmailer 是经过反复检验的类,可运行于各种环境中
      

  9.   

    linux下需要sendmail或者postfix支持
    可查看一下/var/log/maillog日志查看一下具体的错误信息.
      

  10.   

    function和下面的表单在同一个页面的,在windows下发邮件一点问题没有。为什么到linux下就不行了啊 
      

  11.   

    安装了sendmail,但是在终端用mail 命令也发不了邮件
      

  12.   

    因为sendmail 不管用,我remove了sendmail ,然后安装了postfix。出现下面的记录。 不知道是什么原因,应该是postfix没有安装好吧。那个大侠拯救一下啊Dec  2 20:20:01 rafe-HP  postfix/pickup[3343]: 57F56141663: uid=118 from=<smmsp>Dec 2 20:20:01 rafe-HP postfix/cleanup[3364]: 57F56141663: message-id=<20121202122001.57F56141663@rafe-HP>Dec  2 20:20:01 rafe-HP postfix/qmgr[1205]: 57F56141663: from=<smmsp@rafe-HP>, size=752, nrcpt=1 (queue active)Dec  2 20:20:01 rafe-HP postfix/local[3366]: 57F56141663: to=<root@rafe-HP>, orig_to=<root>, relay=local, delay=0.18, delays=0.12/0.01/0/0.05, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")Dec  2 20:20:01 rafe-HP postfix/qmgr[1205]: 57F56141663: removed