如何在共享托管环境中安装phpMailer? [英] How to install phpMailer in a shared hosting environment?

查看:67
本文介绍了如何在共享托管环境中安装phpMailer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在共享主机环境中安装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的PHP​​Mailer的工作示例:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆