/* * Send contact form into email system with attachments * See: https://stackoverflow.com/questions/12301358/send-attachments-with-php-mail * https://github.com/PHPMailer/PHPMailer/ * */ use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require './PHPMailer/src/Exception.php'; require './PHPMailer/src/PHPMailer.php'; require './PHPMailer/src/SMTP.php'; require_once('servicesList.php'); require_once('featuresList.php'); $formTemplate = './myform.php'; $thankyouTemplate = './thankyou_tmpl.php'; $nobotsTemplate = './nobots_tmpl.php'; $errorOutTemplate = './errorOut_tmpl.php'; $upload_dir = "/tmp/"; $cfg = array(); //$cfg['MODE'] = 'DEVEL'; $cfg['MODE'] = 'LIVE'; // note there is also a possible attachment $cfg['validFormVars'] = array('category','subcategory','shortDesc','propertyname','mcid','nameFreeForm','phoneNumber','email','detailedDesc'); $cfg['fromEmail'] = 'support@maestropms.com'; if ($cfg['MODE'] == 'DEVEL') { $cfg['destEmail'] = 'mfowle@maestropms.com'; $cfg['SMTP_host'] = 'bandicoot.northwind.ca'; $cfg['SMTP_port'] = '25'; } elseif ($cfg['MODE'] == 'LIVE') { $cfg['destEmail'] = 'contactuscatch@northwind.ca'; $cfg['SMTP_host'] = 'bandicoot.northwind.ca'; $cfg['SMTP_port'] = '25'; } function errorOut($errorMsg) { global $errorOutTemplate; error_log("Failing contact us form: " . $errorMsg); require($errorOutTemplate); die; } function saveAttachements() { global $upload_dir; $uploadOk = 1; // if file uploaded save to uploaddir and pass info back to MAIN if (! isset( $_FILES["fileToUpload"]["name"] ) || $_FILES["fileToUpload"]["name"] == '') { return(''); } $target_file = $upload_dir . basename($_FILES["fileToUpload"]["name"]); if (file_exists($target_file)) { errorOut( "Sorry, file already exists."); $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 5000000 ) { errorOut( "Sorry, your file is too large."); $uploadOk = 0; } if ($_FILES["fileToUpload"]["size"] < 5 ) { errorOut( "Sorry, your file is too small."); $uploadOk = 0; } // Meat: if ($uploadOk) { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { return($target_file); } else { errorOut( "Sorry, there was an error uploading your file." ); } } error_log("why am I here?"); } function bodyBuilder() { global $cfg; global $features; global $services; $body = ''; $body .= 'genFrom: Contact Support Form' . "\n"; $body .= "EMAIL Version: 1.0\n"; $body .= "Local Time: " . date(DATE_RFC2822) . "\n"; $body .= "\n"; $body .= "Category: " . $_REQUEST['category'] . ' - ' . $services[$_REQUEST['category']] . "\n\n"; $body .= "Subcategory:\n"; foreach ($_REQUEST['subcategory'] as $feature) { if (! isset($feature)) { continue; } $body .= " Feature: " . $feature . ' - ' . $features[$feature] . "\n"; } #$body .= "\nShort Description: " . $_REQUEST['shortDesc'] . "\n\n"; $body .= "\nProperty Name: " . $_REQUEST['propertyname'] . "\n\n"; $body .= "Maestro Client ID: " . $_REQUEST['mcid'] . "\n\n"; $body .= "Name: " . $_REQUEST['nameFreeForm'] . "\n\n"; $body .= "Phone: " . $_REQUEST['phoneNumber'] . "\n\n"; $body .= "Email: " . $_REQUEST['email'] . "\n\n"; $body .= "Detailed Description: " . $_REQUEST['detailedDesc'] . "\n\n"; #$body .= "