用phpmailer类做发送邮件功能,提示500错误?
我用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 <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";
这代码是这样的,按实例来的
提示两行代码,没读懂是什么意思
在php文件页头加上
date_default_timezone_set("PRC"); 试试看。
或者php.ini 中设置时区: date.timezone=PRC

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Alipay PHP...

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
