We have a PHP document which is connected to an online job application form on our website.
Naturally, the application details of the candidate go to us in the form of a transactional email (the top part of the PHP document) whilst at the bottom of the PHP document, attached, details the sending of a confirmation transactional email which is sent to the sender of the application.
The SMTP server is provided by SendGrid, whom are a very reputable company. This SMTP email address is specified in the $email_from
section.
All domains included in the PHP document are legitimate domains, as they are our own.
My Outlook email client, however, states that it cannot verify the senders identification, hence why it is placed into the SPAM. My Office 365 Administration settings on SPAM policy make no difference.
Both emails (the job application and the confirmation email) are both received upon testing - that's isn't an issue.
I would set up an Outlook rule stating that all emails with the appropriate headers are placed straight into our inbox, however, more than one person is receiving these applications into their own emails clients, so it wouldn't be practical to keep reminding them to check their spam as applications can easily be lost in spam folder's.
My question is, how would I prevent any email associated with this PHP document from going straight into the SPAM folder?
I appreciate that different ISP providers and/or email clients have differing criteria on what is deemed as spam versus what is not, so I appreciate that there isn't a fool-proof way out there, however considering that all our domains are legitimate I fail to see why nothing I try works.
Thanks!
<?php
$title = $_POST['title'];
$first = $_POST['first'];
$surname = $_POST['surname'];
$depotPreference = $_POST['depotPreference'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$address3 = $_POST['address3'];
$address4 = $_POST['address4'];
$email = $_POST['email'];
$number = $_POST['number'];
$drivinglicence = $_POST['drivinglicence'];
$dvlacheckcode = $_POST['dvlacheckcode'];
$userMessage = $_POST['userMessage'];
$RightToWork = $_POST['RightToWork'];
$email_from = "$first $surname, <our-sendgrid-smtp-server-address@azure.com";
$Password = 'SMTP PASSWORD';
$email_subject = "You have a new NOD application from $first $surname.";
$email_body =
"User title: $title. \n". "User First Name: $first.\n"."User Surname Name: $surname. \n"."Depot Preference: $depotPreference.\n"."House Name / Number: $address1. \n"."Street Name: $address2. \n"."Town / City: $address3. \n"."Post Code: $address4. \n"."User email: $email. \n"."User Contact Number: $number.\n"."Right to work in the UK: $RightToWork. \n"."Last 8 digits of drivers licence number: $drivinglicence.\n"."DVLA Check Code: $dvlacheckcode.\n"."Applicants prior experience: $userMessage.\n\n\n"."If this is an application for a DA, please confirm all information is correct by going to https://www.viewdrivingrecord.service.gov.uk/driving-record/validate?_ga=2.194915242.60848212.1571236007-425916386.1568197951.\n";
$headers = "From: $email_from" . "\r\n" . "Bcc: mailbox-1@our-domain.com, mailbox-2@our-domain.co.uk, mailbox-3@our-domain.co.uk, mailbox-4@our-domain.com" . "\r\n" . "Reply to: $first $surname". "\r\n" . "Please ensure that this is replied to promptly.";
$headers = 'From: support@our-domain.co.uk' . "\r\n" .'Reply-To: $email' . "\r\n" .'X-Mailer: PHP/' . phpversion();
mail($to, $email_subject, $email_body, $headers, "-fsupport@our-domain.co.uk");
header('Location: https://www.our-domain.com/pages/thank-you.html');
/* Prepare autoresponder subject */
$respond_subject = "Recruitment | Our Company Name";
/* Prepare autoresponder message */
$respond_message = "Hi $first.
Thank you for applying to us for the role of the Delivery Driver! We will aim to reply to you within 24 hours.
Best of luck!
Yours sincerely,
<Our Company Name>";
$headers = 'From: support@our-domain.co.uk' . "\r\n" . //I'm trying to change this to 'From: <Custom Header> ,support@our-domain.co.uk' without this going into OUR RECIPIENTS spam'Reply-To: $email' . "\r\n" .'X-Mailer: PHP/' . phpversion();
/* Send the message using mail() function */
mail($email, $respond_subject, $respond_message, $headers, "-fsupport@our-domain.co.uk");
//}
?>