JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3RbrsetUsername( $sendingAccountUsername ) ->setPassword( $sendingAccountPassword ); } $mailer = Swift_Mailer::newInstance($transport); // Creating the message text using fields sent through POST foreach ($_POST as $key => $value) { if($key !== 'g-recaptcha-response' && $key !== 'captcha'){// Sets of checkboxes will be shown as comma-separated values as they are passed in as an array. if(is_array($value)){ $value = implode(', ' , $value); } $messageText .= '
  • '.ucfirst($key).": ".$value."
  • "; } } if(isset($_POST['email']) && isset($_POST['name']) ){ $fromArray = array($_POST['email'] => $_POST['name']); }else{ $fromArray = array($sendingAccountUsername => $websiteName); } $message = Swift_Message::newInstance($emailSubject) ->setSender(array($sendingAccountUsername => $websiteName)) ->setFrom($fromArray) ->setReplyTo($fromArray) ->setTo(array($recipientEmail => $recipientName))->setBody($htmlHead.$messageText.$htmlFoot, 'text/html'); // Send the message or catch an error if it occurs. try{ echo($mailer->send($message)); if($saveToCSV !== false){ // Save to CSV file $file = fopen($saveToCSV, 'a'); $data = array_values($_POST); $data = array_merge(array( date("Y-m-d H:i:s")), $data); fputcsv_eol($file, $data,"\n"); fclose($file); } } catch(Exception $e){ echo($e->getMessage()); } if($sendConfirmationToUser !== false){ // Get the confirmation template from mail.php - if it is false, no confirmation will be sent. $confirmationTemplate = file_get_contents($sendConfirmationToUser); if($emailMethod == 'phpmail'){ $transport = Swift_MailTransport::newInstance(); }elseif($emailMethod == 'smtp'){ $transport = Swift_SmtpTransport::newInstance( $outgoingServerAddress, $outgoingServerPort, $outgoingServerSecurity ) ->setUsername( $sendingAccountUsername ) ->setPassword( $sendingAccountPassword ); } $mailer = Swift_Mailer::newInstance($transport); if(isset($_POST[$userEmailField])){ if(isset($_POST['name'])){ $userName = $_POST['name']; }else{ $userName = $defaultUserName; } $message = Swift_Message::newInstance($confirmationSubject) ->setFrom(array($sendingAccountUsername => $confirmationFromName)) ->setTo(array($_POST[$userEmailField] => $userName))->setBody($confirmationTemplate, 'text/html'); // Send the message or catch an error if it occurs. $mailer->send($message); }else{ exit; } } exit; function fputcsv_eol($fp, $array, $eol) { fputcsv($fp, $array,',', '"'); if("\n" != $eol && 0 === fseek($fp, -1, SEEK_CUR)) { fwrite($fp, $eol); } } ?>