1
這裏是我的表單,行動和其他一切應該是正確的我的HTML,我想它可能是我的PHP?PHP梅勒給我錯誤404
<form class="form-inline" role="form" method="post" action="index.php">
<div class="form-group">
<label for="inputName">Name</label>
<input type="text" class="form-control" id="inputName" placeholder="Jane Doe">
</div>
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="[email protected]">
<button type="submit" class="btn btn-default" id="formBtn">Send Email</button>
</div>
</form>
這是我的PHP,我複製,然後改變了細節,從GitHub適合自己。
<?php
require 'phpMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 3;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->From = '[email protected]';
$mail->FromName = 'Bradley';
$mail->addAddress('[email protected]', 'Brad'); // Add a recipient
$mail->addReplyTo('[email protected]', 'Reply address');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Email from Vote Unanimous';
$mail->Body = 'You have a new email from your Vote Unanimous account. You should have a name and new email';
$mail->AltBody = 'You have a new email from your Vote Unanimous account. You should have a name and new email';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
很可能您錯誤地鏈接了自動加載文件,將其放在您的電子郵件發送文件所在的同一目錄中,然後修改'require'; – Akshay
是從github窗體實際調用'index.php'來匹配'action =「index.php」' – RiggsFolly