Whenever I uses “URGENT” OR “important” on smtp mail setting my site shows 501 error SITE doesnt work with both tags i want to send an Mail with high importance tag so thats whenever used. but… this error appears always
I have already tried after removing i was also Thought that time but it isnt working the Problem is only with URGENT AND IMPORTANT after the subject, I Just that I just want to Send Mail WITH “Important Tag” with High Priority i set on mail it was 1 Since 1 Is the Highest Priority level To Send an Email but still Whenever someones Recieves It doesnt comes with Important tag -_-
Ok In the morning, I went to the office and find out that what has happened after changing the code. Because I don’t have a laptop or computer right now, I went to the office to check and updated it after using your code. Ok thanks anyways. YOU can read My Previous Messages Also Brother Priority 1 is highest Tho
this is my full code now of this page and the errors u can check i have turned it on also dopenews.in/submit
session_start();
// Basic check to make sure the form was submitted.
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
redirectWithError("The form must be submitted with POST data.");
}
// Do some validation, check to make sure the name, email and message are valid.
if (empty($_POST['g-recaptcha-response'])) {
redirectWithError("Please complete the CAPTCHA.");
}
$recaptcha = new \ReCaptcha\ReCaptcha(CONTACTFORM_RECAPTCHA_SECRET_KEY);
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_REQUEST['REMOTE_ADDR']);
if (!$resp->isSuccess()) {
$errors = $resp->getErrorCodes();
$error = $errors[0];
$recaptchaErrorMapping = [
'missing-input-secret' => 'No reCAPTCHA secret key was submitted.',
'invalid-input-secret' => 'The submitted reCAPTCHA secret key was invalid.',
'missing-input-response' => 'No reCAPTCHA response was submitted.',
'invalid-input-response' => 'The submitted reCAPTCHA response was invalid.',
'bad-request' => 'An unknown error occurred while trying to validate your response.',
'timeout-or-duplicate' => 'The request is no longer valid. Please try again.',
];
$errorMessage = $recaptchaErrorMapping[$error];
redirectWithError("Please retry the CAPTCHA: " . $errorMessage);
}
if (empty($_POST['name'])) {
redirectWithError("Please enter your name in the form.");
}
if (empty($_POST['email'])) {
redirectWithError("Please enter your email address in the form.");
}
if (empty($_POST['subject'])) {
redirectWithError("Please enter your message in the form.");
}
if (empty($_POST['message'])) {
redirectWithError("Please enter your message in the form.");
}
if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
redirectWithError("Please enter a valid email address.");
}
if (strlen($_POST['message']) < 10) {
redirectWithError("Please enter at least 10 characters in the message field.");
}
// Everything seems OK, time to send the email.
function newMail()
{
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
$mail->isSMTP();
$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
$mail->SMTPAuth = true;
$mail->Username = CONTACTFORM_SMTP_USERNAME;
$mail->Password = CONTACTFORM_SMTP_PASSWORD;
$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
$mail->Port = CONTACTFORM_SMTP_PORT;
$mail->Priority = 1;
$mail->AddCustomHeader(“X-Priority: 1”);
$mail->AddCustomHeader(“X-MSMail-Priority: High”);
$mail->AddCustomHeader(“Importance: High”);
$mail->setFrom(CONTACTFORM_FROM_ADDRESS, CONTACTFORM_FROM_NAME);
return $mail;
}
// SEND EMAIL FOR INTERNAL
$mail = newMail();
$mail->addAddress(CONTACTFORM_TO_ADDRESS, CONTACTFORM_TO_NAME);
$mail->Subject = "[Dopenews.in] Submission Confirmation" . $_POST[dopenews.in];
$mail->Body = <<<EOT
Customer Name: {$_POST['name']}
Customer Email: {$_POST['email']}
Customer Message:
{$_POST['message']}
EOT;
try {
$mail->send();
} catch (Exception $ex) {
error_log("PHPMailer Exception: " . print_r($ex->errorMessage(), true));
redirectWithError("An error occurred while trying to send your message.");
}
// SEND EMAIL FOR VISITOR
$mail = newMail();
$mail->addAddress($_POST['email'], $_POST['name']);
$mail->addReplyTo(CONTACTFORM_TO_ADDRESS, CONTACTFORM_TO_NAME);
$mail->Subject =IMPORTANT:"Submission Confirmation" . $_POST[dopenews.in];
$mail->Body = <<<EOT
Dear {$_POST['name']},
Thanks for messaging us. We have received your email, and we'll respond to you within 24-48 hours. For the fastest response, you can use Instagram to contact us.
Regards,
Dopenews Developer Team
www.dopenews.in
EOT;
try {
$mail->send();
} catch (Exception $ex) {
error_log("PHPMailer Exception: " . print_r($ex->errorMessage(), true));
redirectWithError("An error occurred while trying to send your message.");
}
redirectSuccess();```