эй, поэтому я пытался отправить письмо человеку, который заполнил форму на моем сайте, но я новичок в программировании, и я получаю ошибку 500, когда я запускаю код ниже. Или есть какие-либо другие способы автоматической отправки электронной почты для заполнения формы
if (isset($_POST['gp_save_idelegateadd_onsite'])) {
*use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/Exception.php';
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
$lastname = $_GET['gp_applicant_lastname'];
$email = $_GET['gp_applicant_mail'];
/* creates object */
$mail = new PHPMailer(true);
$mailid = $email;
$subject = "GOMailer - Regarding your ESMUN 2020 application.";
$text_message = "Hello";
$message = "Dear $lastname , your application is recieved to be reviewed.";
try {
$mail->IsSMTP();
$mail->isHTML(true);
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Host = "mail.gelecekodakliakademi.com";
$mail->Port = '587';
$mail->AddAddress($mailid);
$mail->Username ="system@gelecekodakliakademi.com";
$mail->Password ="-----]";
$mail->SetFrom('system@gelecekodakliakademi.com','NoReply_GOMailer');
$mail->AddReplyTo("system@gelecekodakliakademi.com","NoReply_GOMailer");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if($mail->Send()) { echo "Thank you for register u got a notification through the mail you provide"; } }
catch(phpmailerException $ex)
{ $msg = " ".$ex->errorMessage()." "; }*
// Form to Database
$addconfig=$db->prepare("INSERT INTO applications SET
gp_applicant_name = :gp_applicant_name,
gp_applicant_lastname = :gp_applicant_lastname,
gp_applicant_birthdate = :gp_applicant_birthdate,
gp_applicant_mail = :gp_applicant_mail,
gp_applicant_gender = :gp_applicant_gender,
gp_applicant_city = :gp_applicant_city,
gp_applicant_gsm = :gp_applicant_gsm,
gp_applicant_school = :gp_applicant_school,
gp_applicant_faculty = :gp_applicant_faculty,
gp_applicant_munrel = :gp_applicant_munrel,
gp_applicant_munrellist = :gp_applicant_munrellist,
gp_applicant_pref1 = :gp_applicant_pref1,
gp_applicant_pref2 = :gp_applicant_pref2,
gp_applicant_pref3 = :gp_applicant_pref3,
gp_applicant_letter = :gp_applicant_letter,
gp_applicant_condition = :gp_applicant_condition,
gp_applicant_what = :gp_applicant_what,
gp_applicant_status = :gp_applicant_status ");
$insert=$addconfig->execute(array(
'gp_applicant_name' => $_POST['gp_applicant_name'],
'gp_applicant_lastname' => $_POST['gp_applicant_lastname'],
'gp_applicant_birthdate' => $_POST['gp_applicant_birthdate'],
'gp_applicant_mail' => $_POST['gp_applicant_mail'],
'gp_applicant_gender' => $_POST['gp_applicant_gender'],
'gp_applicant_city' => $_POST['gp_applicant_city'],
'gp_applicant_gsm' => $_POST['gp_applicant_gsm'],
'gp_applicant_school' => $_POST['gp_applicant_school'],
'gp_applicant_faculty' => $_POST['gp_applicant_faculty'],
'gp_applicant_munrel' => $_POST['gp_applicant_munrel'],
'gp_applicant_munrellist' => $_POST['gp_applicant_munrellist'],
'gp_applicant_pref1' => $_POST['gp_applicant_pref1'],
'gp_applicant_pref2' => $_POST['gp_applicant_pref2'],
'gp_applicant_pref3' => $_POST['gp_applicant_pref3'],
'gp_applicant_letter' => $_POST['gp_applicant_letter'],
'gp_applicant_condition' => $_POST['gp_applicant_condition'],
'gp_applicant_what' => $_POST['gp_applicant_what'],
'gp_applicant_status' => $_POST['gp_applicant_status'] ));
// Feedback
if ($insert) {
header("Location:../../../apply.php?view=delegate&apply=ok");
} else {
header("Location:../../../apply.php?view=delegate&apply=err");
}
}
часть
*use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'phpmailer/Exception.php';
require 'phpmailer/PHPMailer.php';
require 'phpmailer/SMTP.php';
$lastname = $_GET['gp_applicant_lastname'];
$email = $_GET['gp_applicant_mail'];
/* creates object */
$mail = new PHPMailer(true);
$mailid = $email;
$subject = "GOMailer - Regarding your ESMUN 2020 application.";
$text_message = "Hello";
$message = "Dear $lastname , your application is recieved to be reviewed.";
try {
$mail->IsSMTP();
$mail->isHTML(true);
$mail->SMTPDebug = 0;
$mail->SMTPAuth = true;
$mail->Host = "mail.gelecekodakliakademi.com";
$mail->Port = '587';
$mail->AddAddress($mailid);
$mail->Username ="system@gelecekodakliakademi.com";
$mail->Password ="-----]";
$mail->SetFrom('system@gelecekodakliakademi.com','NoReply_GOMailer');
$mail->AddReplyTo("system@gelecekodakliakademi.com","NoReply_GOMailer");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AltBody = $message;
if($mail->Send()) { echo "Thank you for register u got a notification through the mail you provide"; } }
catch(phpmailerException $ex)
{ $msg = " ".$ex->errorMessage()." "; }*
Я верю, что вызвало ошибку, потому что, когда я удаляю ее, форма отправляется в базу данных без вопрос, спасибо.