簡體   English   中英

帶Mmail的PHPMailer-不起作用

[英]PHPMailer w/Gmail - Not Working

我最近一直在學習PHP,因此我需要能夠使用它發送電子郵件。

我發現PHPMailer是發送郵件的好方法,因此我嘗試了一下。 我已經根據可以找到的所有示例設置了代碼,但是仍然無法使它正常工作。

這是我的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>";
}

?>

當我單擊“提交”按鈕以發送上一頁的表單時,它將帶我到/mail.php?name=aName&email=anEmail&m=aMsg並回顯該頁面,但它沒有發送電子郵件。

當我打開Chrome開發工具時:

“ devicemotion事件在不安全的來源上已被棄用,將來將取消支持。您應該考慮將應用程序切換到安全來源,例如HTTPS。有關更多詳細信息,請參閱。”

但是,我很確定這是由嵌入式Vimeo播放器而不是PHPMailer引起的。

如果有人可以在這里幫我忙,那:D

我解決了自己的問題。

當我提到我認為加載不正確時,這是正確的一半。

為了解決這個問題,我將其余的.php文件添加到了與自動加載器相同的目錄中。 我認為自動裝帶器會自動包括所有這些裝帶器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM