Jump to content

justspiffy

Members
  • Posts

    32
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

justspiffy's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey everyone, I purchased a template to make a website with and need a little bit of help with altering the contact form. The form works fine, when someone fills out the form online and the email comes to me, the reply to email address is the one they inputted into the form. However, when I click "reply" in the email, it changes to my email address(the $fromEmail which I was trying to override) Here is the send.php <?php $ajax = (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); $ajax = true; //we do not allow direct script access if (!$ajax) { //redirect to contact form echo "Please enable Javascript"; exit; } require_once "config.php"; //we set up subject $mail->Subject = isset($_REQUEST['email_subject']) ? $_REQUEST['email_subject'] : "Message from site"; //let's validate and return errors if required $data = $mail->validateDynamic(array('required_error' => $requiredMessage, 'email_error' => $invalidEmail), $_REQUEST); //let's make sure we have valid data //if (!$data['errors'] && (!isset($_REQUEST['js']) || $_REQUEST['js'] != 1)) { //$data['errors']['global'] = 'Javascript is required. Please try again'; //} if ($data['errors']) { echo json_encode(array('errors' => $data['errors'])); exit; } //force to overwrite email address $mail->SetFrom($data['fields']['Email'], $data['fields']['Name'].' '.$data['fields']['Surname']); $html = '<body style="margin: 10px;"> <div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;"> <h2>' . $mail->Subject . '</h2> '; foreach ($data['fields'] as $label => $val) { $html .= '<p>' . $label . ': ' . $val . '</p>'; } $html .= '</div></body>'; $mail->setup($html, $_REQUEST, array()); $result = array('success' => 1); if (!$mail->Send()) { $result['success'] = 0; } echo json_encode($result); exit; config.php <?php /** * Setup mail server config */ ini_set('display_errors', 0); //where we would like to send email $recipientEmail = '[email protected]'; $recipientName = 'The Touchmark'; //Address which will be visible in "From" field $fromEmail = '[email protected]'; $fromName = 'Site Admnistrator'; //Validation error messages $requiredMessage = 'Field is required'; $invalidEmail = 'Invalid email'; /** * Advanced configuration - no need to modify */ require_once(dirname(__FILE__) . '/vendor/ctPHPMailer.php'); $mail = new ctPHPMailer(); //set your email address $mail->AddAddress($recipientEmail, $recipientName); $mail->SetFrom($fromEmail, $fromName); $debug = false; //if problems occur, set to true to view debug messages I do not know much about php so I am not sure what to do to make it stay as the users email address when they click "reply" on the email. Any ideas would be great.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.