【发布时间】:2017-09-20 22:49:15
【问题描述】:
我在搞乱phpmailer,我已经让一切正常了。
但是我现在要做的是在提交表单后发送邮件。
没什么太难的,只是一封确认表单已提交的基本电子邮件(没有表单数据)。
问题:提交表单后电子邮件未发送(电子邮件代码工作 100% 测试)
希望有人可以帮助我:)
mail.php 代码:
<?php
//ini_set(‘display_errors’, 1);
include '/var/www/includes/mailer.php';
//require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.nicetrygoyim.nl'; //Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'secret@secret.com'; // SMTP username
$mail->Password = 'nicetry'; // SMTP password
$mail->SMTPSecure = 'TLS'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('secret@secret.com', 'Mailer');
$mail->addAddress('secret@secret.com', 'secret'); // Add a recipient
$mail->addAddress('secret@secret.com', 'secret'); // Name is optional
//$mail->addReplyTo('secret@secret.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$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 = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->smtpConnect([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
]
]);
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
?>
我的表格:
<form action="mail.php" method="post">
Leerlingnummer:<br>
<input type="text" name="leerlingnummer"required placeholder="Voer hier het leerlingnummer in" /><br>
E-mailadres:<br>
<input type="submit" name="submit" class="groottext" value="Reparatie indienen"/>
编辑:错字
编辑:忘了提问题
【问题讨论】:
-
你使用哪个服务器?
-
@DhruvinMoradiya 我使用自己的服务器(debian 8)
-
有什么问题??什么不工作?
-
@LelioFaieta 哦,我忘了说。
-
@LelioFaieta 我已经编辑了它,所以它提到了我的问题:)
标签: php html forms email phpmailer