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