用phpmailer類做發送郵件功能,提示500錯誤?

來源:互聯網
上載者:User
我用phpmailer類做發送郵件功能,提示500錯誤Internal Server Error;
調用代碼都應該沒問題,接網上執行個體寫的,
是不是在做這個功能之前,還需要什麼別的步驟或配置才可以發送郵件呢?


回複討論(解決方案)

出現 500 錯誤就表示你的代碼有問題!
開啟 php 的錯誤顯示功能,調試一下

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log

一運行就直接提示這個了,也沒報什麼錯。

require("./class.phpmailer.php");$mail = new PHPMailer();$mail->IsSMTP();// 啟用SMTP$mail->Host = "smtp.sina.cn";//SMTP伺服器$mail->SMTPAuth = true;//開啟SMTP認證$mail->Username = "fgrhda";// SMTP使用者名稱$mail->Password = "123456";// SMTP密碼$mail->From = "fgrhda@163.com";//寄件者地址$mail->FromName = "Mailer";//寄件者$mail->AddAddress("97235694@qq.com", "Josh Adams");//添加收件者//$mail->AddAddress("ellen@example.com");$mail->AddReplyTo("97235694@qq.com", "Information");//回複地址$mail->WordWrap = 50;//設定每行字元長度/** 附件設定$mail->AddAttachment("/var/tmp/file.tar.gz");// 添加附件$mail->AddAttachment("/tmp/image.jpg", "new.jpg");// 添加附件,並指定名稱*/$mail->IsHTML(true);// 是否HTML格式郵件$mail->Subject = "Here is the subject";//郵件主題$mail->Body    = "This is the HTML message body in bold!";//郵件內容$mail->AltBody = "This is the body in plain text for non-HTML mail clients";//郵件內文不支援HTML的備用顯示if(!$mail->Send()){   echo "Message could not be sent. 

"; echo "Mailer Error: " . $mail->ErrorInfo; exit;}echo "Message has been sent";


這代碼是這樣的,按執行個體來的

提示兩行代碼,沒讀懂是什麼意思

在php檔案頁頭加上
date_default_timezone_set("PRC"); 試試看。
或者php.ini 中設定時區: date.timezone=PRC

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.