Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- ini_set('display_errors', '0');
- ob_start();
- //extract all form values into variables by key name. I.E. $_POST["from_name"] becomes $from_name
- extract($_POST);
- //Initialize non-form variables.
- $valid = false;
- $sent = false;
- $html = '';
- $from = '';
- $to = '';
- $cc = '';
- $bcc = '';
- $headers = '';
- $response = '';
- //Check if extract worked and if not spam.
- if (isset($special) && $special == "")
- {
- //Check required fields, $from_name cannot be empty, and if $preferred is "phone" neither can
- //$from_phone, otherwise neither can $from_email
- $valid = (trim($from_name) != "" &&
- (($preferred == "phone" && trim($from_phone) != "") || (trim($from_email) != "")) &&
- (trim($from_city) != "") && (trim($from_zip) != "") &&
- (trim($to_city) !="") && (trim($to_zip) ! ="") &&
- (($hazard != "checked") ||
- (trim($hclass) != "" && trim($un) != ""))
- );
- if ($valid)
- {
- //Build the HTML Body of the email
- $html = <<<EOT
- <h1>Pronto Quote Request Email</h1>
- <h2>From:</h2>
- <p><b>Requested by:</b> $from_name</p>
- <p><b>Company:</b> $from_contact</p>
- <p><b>City:</b> $from_city</p>
- <p><b>State:</b> $from_state</p>
- <p><b>Zip Code:</b> $from_zipcode</p>
- <p><b>Country:</b> $from_country</p>
- <p><b>Phone:</b> $from_phone</p>
- <p><b>Email:</b> $from_email</p>
- <p><b>Preferred:</b> $preferred</p>
- <h2>To:</h2>
- <p><b>City:</b> $to_city</p>
- <p><b>State:</b> $to_state</p>
- <p><b>Zip Code:</b> $to_zipcode</p>
- <p><b>Country:</b> $to_country</p>
- <h2>Packages:</h2>
- <p><b>Pieces:</b> $pieces</p>
- <p><b>Skid:</b> $skid</p>
- <p><b>Weight (Lbs):</b> $weight</p>
- <p><b>Dimensions:</b> $dimensions</p>
- <p><b>Hazardous class:</b> $hclass</p>
- <p><b>Hazardous UN #:</b> $un</p>
- <p><b>Ready by:</b> $readyTime</p>
- <p><b>Deliver by:</b> $deliveryTime</p>
- <h2>Other:</h2>
- <p><b>Vehicle:</b> $vehicle</p>
- <h2>Comments:</h2>
- <p>$comment</p>
- EOT;
- //Setup who it goes to and comes from
- //To add more to To, CC or Bcc, add strings to Array
- $from = 'sales@pronto-delivery.com';
- $to = array(
- // 'sales@pronto-delivery.com',
- 'hrozo@hatalasystemsgroup.com',
- );
- $cc = array(
- // 'jack.chambers@pronto-deliver.com',
- );
- $bcc = array(
- // 'hrozo@hatalasystemsgroup.com',
- // 'cwrinn@hatalasystemsgroup.com',
- );
- //Set to HTML email
- $headers = 'MIME-Version: 1.0' . "\r\n";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
- //Additional headers for From, Cc, Bcc and Mailer
- $headers .= 'From: ' . $from . "\r\n";
- $headers .= 'Cc: ' . join(';', $cc) . "\r\n";
- $headers .= 'Bcc: ' . join(';', $bcc) . "\r\n";
- $headers .= 'X-Mailer: PHP/' . phpversion();
- $subject = "Quote Request: $from";
- //attempt to send email
- print($html); $sent = true;
- //$sent = mail(join(';', $to), $subject, $html, $headers);
- if ($sent)
- {
- //Email send successful
- $response = 'Thank you for your request.<br>'.
- 'A Customer Service representative will respond shortly with the information.';
- }
- else
- {
- //Email send unsuccessful
- $response = 'There was a problem sending the email. Please try again.';
- }
- }
- else
- {
- $response = 'Missing Required Fields. Please ensure Name and either Phone or Email are filled in.';
- }
- }
- else
- {
- $response = 'No Spam Allowed!';
- }
- print($response);
- //Log
- $log_data = array(
- "Date" => date("Ymd\TT"),
- "User Agent" => $_SERVER["HTTP_USER_AGENT"],
- "SpamString" => (isset($special))?$special:'',
- "Validates" => ($valid)?"True":"False",
- "From" => $from,
- "To" => join(';', $to),
- "Cc" => join(';', $cc),
- "Bcc" => join(';', $bcc),
- "Message" => str_replace("\n", "<br>", htmlspecialchars($html)),
- "Response" => htmlspecialchars($response),
- "Sent" => ($sent)?"True":"False",
- );
- file_put_contents('./quoterequest.log', json_encode($log_data) . "$||$", FILE_APPEND);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement