用phpmailer类做发送邮件功能,提示500错误?

静心聆听_心如止水 2013-04-18 12:28:57
我用phpmailer类做发送邮件功能,提示500错误Internal Server Error;
调用代码都应该没问题,接网上实例写的,
是不是在做这个功能之前,还需要什么别的步骤或配置才可以发送邮件呢?
...全文
461 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
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 <b>in bold!</b>";		//邮件内容
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";	//邮件正文不支持HTML的备用显示

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";

这代码是这样的,按实例来的
xuzuning 2013-04-18
  • 打赏
  • 举报
回复
出现 500 错误就表示你的代码有问题! 打开 php 的错误显示功能,调试一下
一起混吧 2013-04-18
  • 打赏
  • 举报
回复
在php文件页头加上 date_default_timezone_set("PRC"); 试试看。 或者php.ini 中设置时区: date.timezone=PRC
  • 打赏
  • 举报
回复
提示两行代码,没读懂是什么意思

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧