简体   繁体   English

带Mmail的PHPMailer-不起作用

[英]PHPMailer w/Gmail - Not Working

I have been recently learning PHP, and I need to be able to send emails using it. 我最近一直在学习PHP,因此我需要能够使用它发送电子邮件。

I have found out that PHPMailer is a great way to send the mail, so I have tried it out. 我发现PHPMailer是发送邮件的好方法,因此我尝试了一下。 I have set up my code according to all of the examples that I can find, but I still am unable to get it to work. 我已经根据可以找到的所有示例设置了代码,但是仍然无法使它正常工作。

Here is my PHP code: 这是我的PHP代码:

<?php

error_reporting(E_ALL);

$fc = file_get_contents("http://redxtech.ca/fbm/");

echo $fc;


if (isset($_GET["name"]) && isset($_GET["email"]) && isset($_GET["m"])) {
    $name = $_GET["name"];
    $email = $_GET["email"];
    $msg = $_GET["m"];
}
else {
    $name = "Blank Name";
    $email = "<email here>";
    $msg = "Blank";
};

$e_msg = "FB:/nYou have recieved a new submission form from " . $name . " at <" . $email . ">./n/nIt says:/n/n" . $msg . "./n/nDo what you wish with this information./n~ Gabe";


require "PHPMailerAutoload.php";

$mail = new PHPMailer;

$mail->SMTPDebug = 1;

$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "<my gmail>";
$mail->Password = "<my super secret password>";
$mail->SMTPSecure = "tls";
$mail->Port = 587;

$mail->setFrom("<my gmail>", "Red's Mailer");
$mail->addAddress("<my other email>", "Gabe");
$mail->addAddress("<another email>", "FB");
$mail->addReplyTo("<my other email>", "Gabe");

$mail->isHTML = true;

$mail->Subject = "New Submission";
$mail->Body = $e_msg;
$mail->AltBody = "This is an altbody.";

if(!$mail->send()) {
    echo "<script>console.log('Mail was not sent')</script>";
    $errInf = $mail->ErrorInfo;
    echo "<script>console.log('Mailer Error: " . $errInf . "')</script>";
} else {
    echo "<script>console.log('Mail was sent')</script>";
}

?>

When I click on the submit button to send the form on the previous page, it takes me to /mail.php?name=aName&email=anEmail&m=aMsg and echo's the page, but it isn't sending the email. 当我单击“提交”按钮以发送上一页的表单时,它将带我到/mail.php?name=aName&email=anEmail&m=aMsg并回显该页面,但它没有发送电子邮件。

When I open up Chrome Dev Tools: 当我打开Chrome开发工具时:

"The devicemotion event is deprecated on insecure origins, and support will be removed in the future. You should consider switching your application to a secure origin, such as HTTPS. See for more details." “ devicemotion事件在不安全的来源上已被弃用,将来将取消支持。您应该考虑将应用程序切换到安全来源,例如HTTPS。有关更多详细信息,请参阅。”

However, I'm pretty sure that is caused by the embedded Vimeo players and not PHPMailer. 但是,我很确定这是由嵌入式Vimeo播放器而不是PHPMailer引起的。

If anyone can give me a hand here that would be great :D 如果有人可以在这里帮我忙,那:D

I fixed my own problem. 我解决了自己的问题。

When I mentioned that I didn't think it was loading properly, that was half correct. 当我提到我认为加载不正确时,这是正确的一半。

To fix it, I added the rest of the .php files into the same directory as the autoloader. 为了解决这个问题,我将其余的.php文件添加到了与自动加载器相同的目录中。 I thought that the autoloader automatically included all of them. 我认为自动装带器会自动包括所有这些装带器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM