我搞亂了phpmailer,我已經得到了一切工作。
但即時嘗試現在要做的是提交表單後發送郵件。 沒有什麼太難,只是一個基本的電子郵件,承認已提交表格(無表格數據)。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 = '[email protected]'; // 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('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'secret'); // Add a recipient
$mail->addAddress('[email protected]', 'secret'); // Name is optional
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$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) –
,這是什麼問題?什麼不起作用? –