Jump to content

Email form including reply to (from) of ftp username and correct email address


OldWest

Recommended Posts

Hello,

I am working with a SMTP class to send an email. It's all working perfectly fine, but when the email is received (sent from the online form), and I open my email and click reply, there are two email addresses. The correct one (which I entered when I sent the email), and my ftp username for the site??

 

I've got three files that could effect this, but I was unable to locate any problems:

mailer.php ( smtp send mail class)

mail.php ( submission data: title, subject, etc. )

contact_form.php ( form for submission )

 

I am only including the file which I think is applicable (mail.php), but let me know if you would also like to see the mailer.php class.

 

Current output:

 

reply-to [email protected],

[email protected]

 

mail.php:

 

<?php
  set_time_limit(120);
  
  function sendHTMLmail($from, $to, $subject, $message)
  {
      $message = wordwrap($message, 70);
      
      // To send HTML mail, the Content-type header must be set
      $headers = 'MIME-Version: 1.0' . "\r\n";
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      
      // Additional headers
      $headers .= "From: $from\r\n";
      
      // Mail it
      mail($to, $subject, $message, $headers);
  }
  
  function sendHTMLmail2($fromid, $to, $subject, $message)
  {
      echo $fromid;
      echo $to;
      echo $subject;
      echo $message;
      include_once("mailer.php");
      $mail = new PHPMailer();
      $mail->IsMail();
      // SMTP servers
      $mail->Host = "localhost";
      $mail->From = $fromid;
      $mail->FromName = $fromid;
      $mail->IsHTML(true);
      $mail->AddAddress($to, $to);
      $mail->Subject = $subject;
      $mail->Body = $message;
      $mail->AltBody = "Please enable HTML to read this";
      $mail->Send();
      exit;
  }
  function isValidEmail($email)
  {
      return eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$", $email);
  }
  
  
  class smtp_mail
  {
      var $host;
      var $port = 25;
      var $user;
      var $pass;
      var $debug = false;
      var $conn;
      var $result_str;
      var $charset = "utf-8";
      var $in;
      var $from_r;
      //mail format 0=normal 1=html
      var $mailformat = 0;
      function smtp_mail($host, $port, $user, $pass, $debug = false)
      {
          $this->host = $host;
          $this->port = $port;
          $this->user = base64_encode($user);
          $this->pass = base64_encode($pass);
          $this->debug = $debug;
          $this->socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
          if ($this->socket) {
              $this->result_str = "Create socket:" . socket_strerror(socket_last_error());
              $this->debug_show($this->result_str);
          } else {
              exit("Initialize Faild,Check your internet seting,please");
          }
          $this->conn = socket_connect($this->socket, $this->host, $this->port);
          if ($this->conn) {
              $this->result_str = "Create SOCKET Connect:" . socket_strerror(socket_last_error());
              $this->debug_show($this->result_str);
          } else {
              exit("Initialize Faild,Check your internet seting,please");
          }
          $this->result_str = "Server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>";
          $this->debug_show($this->result_str);
      }
      
      function debug_show($str)
      {
          if ($this->debug) {
              echo $str . "<p>\r\n";
          }
      }
      
      function send($from, $to, $subject, $body)
      {
          if ($from == "" || $to == "") {
              exit("type mail address please");
          }
          if ($subject == "")
              $sebject = "none title";
          if ($body == "")
              $body = "none content";
          
          $All = "From:$from;\r\n";
          $All .= "To:$to;\r\n";
          $All .= "Subject:$subject;\r\n";
          if ($this->mailformat == 1) {
              $All .= "Content-Type:text/html;\r\n";
          } else {
              $All .= "Content-Type:text/plain;\r\n";
          }
          $All .= "Charset:" . $this->charset . ";\r\n\r\n";
          $All .= " " . $body;
          
          $this->in = "EHLO HELO\r\n";
          $this->docommand();
          
          $this->in = "AUTH LOGIN\r\n";
          $this->docommand();
          
          $this->in = $this->user . "\r\n";
          $this->docommand();
          
          $this->in = $this->pass . "\r\n";
          $this->docommand();
          
          if (!eregi("235", $this->result_str)) {
              $this->result_str = "smtp auth faild";
              $this->debug_show($this->result_str);
              return 0;
          }
          
          $this->in = "MAIL FROM: $from\r\n";
          $this->docommand();
          
          $this->in = "RCPT TO: $to\r\n";
          $this->docommand();
          
          $this->in = "DATA\r\n";
          $this->docommand();
          
          $this->in = $All . "\r\n.\r\n";
          $this->docommand();
          
          
          if (!eregi("250", $this->result_str)) {
              $this->result_str = "Send mail faild!";
              $this->debug_show($this->result_str);
              return 0;
          }
          
          $this->in = "QUIT\r\n";
          $this->docommand();
          socket_close($this->socket);
          return 1;
      }
      
      function docommand()
      {
          socket_write($this->socket, $this->in, strlen($this->in));
          $this->debug_show("Client command:" . $this->in);
          $this->result_str = "server answer:<font color=#cc0000>" . socket_read($this->socket, 1024) . "</font>";
          $this->debug_show($this->result_str);
      }
  }
?>

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.