We are using the following PHP code for sending official reports by email. We use to send reports every quarter and it was working fine the last time we used it. But recently we upgraded our Linux server plan on GoDaddy from Deluxe shared hosting plan to Ultimate shared hosting plan and also moved the domain from GoDaddy to Google.
Now I don't understand whether this code is stopped functioning or the server is not functioning properly but the emails are not delivering to the recipients.
I just spoke with GoDaddy tech team, and they sent me the following email:
Troubleshoot results:
Splunk shows bad account. Scan all local computers which may access this account for the presence of malware, such as trojans, keyloggers, viruses, etc. Update all logins associated with your account, using strong passwords, including: FTP, database, and applications, etc. Update and maintain all hosted applications and their add-ons (plugins, themes, widgets, modules, etc) with the most current, secure, versions. Review all hosted content for malicious and unrecognized files, and clean/remove/replace content as necessary. Add a Captcha, or human verification method, to all submission style forms or comment sections that you have on any sites in the hosting. This includes any login pages for CMS application or anything that has fields to enter content with a submission button of some type. Advise us of what steps you have taken to secure the hosting and the steps you plan to take to prevent issues in the future and also there are 16,000 emails in queue.
From this email, I'm believing that this code is working properly but there is something wrong at some place that relates to email service which is not delivering the emails for which I'm unable to figure out. I don't think that there should be some malware that is stopping the mail delivery and I think that GoDaddy speaks from an analysis report generated by Splunk.
Can you guys help me understand all the possible ways to solve this problem?
<?php
function compose_screen($form = false, $formFlag = 0) {
echo '<p>This report form covers all <em>Ten Tips</em> and <em>Love Your Neighbor</em> events including any variations of such presentations.</p>';
switch ($formFlag) {
case 1:
echo '<p class="error">One or more form fields are empty!</p>';
break;
}
echo '<form action="'.$_SERVER[PHP_SELF].'" method="post" id="lynReport">';
echo '<ul><li>';
echo '<label for="yourName">Your name</label>';
echo '<input type="text" id="yourName" name="yourName" required value="'.htmlentities($form['yourName'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="dateEvent">Date of event (or first day of event)</label>';
echo '<input type="text" id="dateEvent" name="dateEvent" required value="'.htmlentities($form['dateEvent'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li class="listInputs">';
echo '<label>Type of event (choose closest description)</label>';
input_radiocheck('radio','typeEvent',$form,'full LYN with field trip',true);
echo '<span>Full LYN with field trip</span>';
input_radiocheck('radio','typeEvent',$form,'full LYN no field trip');
echo '<span>Full LYN, no field trip</span>';
input_radiocheck('radio','typeEvent',$form,'abbreviated LYN');
echo '<span>Abbreviated LYN</span>';
input_radiocheck('radio','typeEvent',$form,'10 tips');
echo '<span>Ten Tips</span>';
input_radiocheck('radio','typeEvent',$form,'expanded 10 tips');
echo '<span>Expanded Ten Tips</span>';
echo '<input type="radio" value="other" name="typeEvent" id="typeOther">';
echo '<span>Other (describe)</span>';
echo '<label class="error" for="typeEvent"></label>';
echo '<input type="text" id="typeEventDescrip" name="typeEventDescrip" value="'.htmlentities($form['typeEventDescrip'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="eventTrainers">Event trainers</label>';
echo '<input type="text" id="eventTrainers" name="eventTrainers" required value="'.htmlentities($form['eventTrainers'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="location">Location (city, state, country)</label>';
echo '<input type="text" id="location" name="location" required value="'.htmlentities($form['location'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="hostPartner">Hosting partner (church, pastor, local organizer)</label>';
echo '<input type="text" id="hostPartner" name="hostPartner" required value="'.htmlentities($form['hostPartner'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="numberAttend">Number attending</label>';
echo '<input type="text" id="numberAttend" name="numberAttend" required value="'.htmlentities($form['numberAttend'], ENT_QUOTES, 'UTF-8').'">';
echo '</li><li>';
echo '<label for="resultFeedback">Results (from feedback forms – How many expressed interest in South Asia Wired, Breakthough cell, other)</label>';
echo '<textarea id="resultFeedback" name="resultFeedback" required>'.htmlentities($form['resultFeedback'], ENT_QUOTES, 'UTF-8').'</textarea>';
echo '</li><li>';
echo '<label for="commentParticipant">Comments from participants (include a few good comments and suggested improvements, with full name)</label>';
echo '<textarea id="commentParticipant" name="commentParticipant" required>'.htmlentities($form['commentParticipant'], ENT_QUOTES, 'UTF-8').'</textarea>';
echo '</li><li>';
echo '<label for="potentialTrainer">Did you identify any potential associate trainer? (must have good communication/teaching skills, active in personal evangelism to Hindus)</label>';
echo '<input type="text" id="potentialTrainer" name="potentialTrainer" required value="'.htmlentities($form['potentialTrainer'], ENT_QUOTES, 'UTF-8').'">';
echo '</li>';
echo '<li>';
echo '<label for="anythingElse">Anything else you would like to share</label>';
echo '<textarea id="anythingElse" name="anythingElse">'.htmlentities($form['anythingElse'], ENT_QUOTES, 'UTF-8').'</textarea>';
echo '</li></ul>';
echo '<div class="finishForm">';
echo '<input type="submit" name="submit" value="Submit" />';
echo '<input type="reset" />';
echo '<input type="hidden" name="emailSent" value="1">';
echo '</div>';
echo '</form>';
}
function email_sent() {
$formFlag = 0;
foreach ($_POST as $key => $value) {
$form[$key] = trim($value);
}
$formErrors = array();
foreach ($form as $k => $v) {
switch ($k) {
case "yourName":
case "dateEvent":
case "eventTrainers":
case "location":
case "hostPartner":
case "numberAttend":
case "resultFeedback":
case "commentParticipant":
case "potentialTrainer":
if (!strlen($v)) {
$formErrors[] = $v;
}
break;
}
}
switch ($_POST['typeEvent']) {
case "full LYN with field trip":
case "full LYN no field trip":
case "abbreviated LYN":
case "10 tips":
case "expanded 10 tips":
case "other":
break;
default:
$formErrors[] = $_POST['typeEvent'];
}
if ($_POST['typeEvent'] == "other") {
if (!strlen($_POST['typeEventDescrip'])) {
$formErrors[] = $_POST['typeEventDescrip'];
}
}
if (count($formErrors) > 0) {
$formFlag = 1;
compose_screen($form, $formFlag);
} else {
email_success($form);
}
}
function email_success($form) {
$mailTo = 'email@example.com';
$mailSubject = 'Love Your Neighbor Report';
$mailContent = 'Love Your Neighbor Report' . "\r\n\r\n";
$mailContent .= 'Name: ' . $form['yourName'] . "\r\n";
$mailContent .= "Date of event: " . $form['dateEvent'] . "\r\n";
$mailContent .= 'Type of event: ' . $form['typeEvent'] . "\r\n";
if ($form['typeEvent'] == "other") {
$mailContent .= 'Describe: ' . $form['typeEventDescrip'] . "\r\n";
}
$mailContent .= 'Event trainers: ' . $form['eventTrainers'] . "\r\n";
$mailContent .= 'Location: ' . $form['location'] . "\r\n";
$mailContent .= 'Hosting partner: ' . $form['hostPartner'] . "\r\n";
$mailContent .= 'Number attending: ' . $form['numberAttend'] . "\r\n";
$mailContent .= 'Results: ' . $form['resultFeedback'] . "\r\n";
$mailContent .= 'Comments from participants: ' . $form['commentParticipant'] . "\r\n";
$mailContent .= 'Potential associate trainer?: ' . $form['potentialTrainer'] . "\r\n";
$mailContent .= 'Anything else to share: ' . $form['anythingElse'];
$mailCheck = mail($mailTo, $mailSubject, $mailContent);
echo '<p class="successParagraph">Your Report has been sent to Nayajeevan Ministries. Thank you for taking the time to talk to us.</p>';
unset($form);
echo '<p class="successParagraph"><a href="http://www.nayajeevan.org/resources/">Nayajeevan Web Site</a></p>';
echo '<p class="successParagraph"><form action="'.$_SERVER[PHP_SELF].'" method="post">';
echo '<input type="submit" name="submit" value="Submit Another Report" />';
echo '<input type="hidden" name="redoReport" value="1">';
echo '</form></p>';
}
include_once "../includes/input_radiocheck.inc";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Love Your Neighbor Report</title>
<link href="../css/prayerReport.css" rel="stylesheet" type="text/css">
<link href="../css/jquery-ui-min.css" rel="stylesheet" type="text/css">
<link href="../css/jquery-ui-structure-min.css" rel="stylesheet" type="text/css">
<link href="../css/jquery-ui-theme-min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="nayajeevanHdr">
<div>
<div class="nayajeevanBanner">
<img src="http://www.example.com/templates/ja_travel/images/logo.png" alt="Naya Jeevan">
</div>
</div>
</div>
<div id="mainWrapper">
<h1>Love Your Neighbor Report Form</h1>
<?php
if ($_POST['redoReport']) {
compose_screen();
} elseif ($_POST['emailSent']) {
email_sent();
} else {
compose_screen();
}
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../javascript/plugins/jquery-validate-min.js" type="text/javascript"></script>
<script src="../javascript/plugins/jquery-ui-min.js" type="text/javascript"></script>
<script>
// code for jQuery Validate plugin
$( "#lynReport" ).validate({
rules: {
typeEventDescrip: {
required: "#typeOther:checked"
}
},
messages: {
typeEvent: "You must select one"
}
});
// code for jQuery UI Datepicker plugin
$( "#dateEvent" ).datepicker({
dateFormat: "M/dd/yy"
});
</script>
</body>
</html>
<?php
?>