如何在共享托管环境中安装phpMailer? [英] How to install phpMailer in a shared hosting environment?
问题描述
如何在共享主机环境中安装phpMailer
?我需要将其用于用户的电子邮件验证和密码更改.
How to install phpMailer
in a shared hosting environment? I need to use this for email verifications and password changing of the users.
推荐答案
您可以在此处下载: https://github.com/PHPMailer/PHPMailer
将文件夹上传到您的服务器,并在主文件行中包含以下内容:
Upload the folder to your server and include the main file with this line:
<?php
require 'phpmailerfolder/PHPMailerAutoload.php';
?>
之后,您将需要一个外部SMTP帐户,例如gmail.com.这是带有GMAIL的PHPMailer的工作示例:
After that, you will need an external SMTP account, like gmail.com for example. Here is a working example of PHPMailer with GMAIL:
<?php
require 'phpmailerfolder/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = "smtp.gmail.com";
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "youremail@gmail.com";
$mail->Password = "yourpassword";
$mail->setFrom('youremail@gmail.com', 'Your Name');
$mail->addAddress('to@site.com', 'To');
$mail->Subject = "Subject";
$mail->Body = "Message";
if (!$mail->send()) {
echo "Error sending message";
} else {
echo "Message sent!";
}
?>
还要确保也在此GMAIL帐户中启用不安全的应用程序": https://support.google.com/accounts/answer/6010255?hl=zh_CN
Make sure to enable "non secure apps" in this GMAIL account too: https://support.google.com/accounts/answer/6010255?hl=en
这篇关于如何在共享托管环境中安装phpMailer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!