+$headers = array();
+
+// if configured, the Received headers goes to top, for good measure
+if ($CONFIG['http_received_header'])
+{
+ $nldlm = "\r\n\t";
+ // FROM/VIA
+ $http_header = 'from ';
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
+ $host = $_SERVER['HTTP_X_FORWARDED_FOR'];
+ $hostname = gethostbyaddr($host);
+ if ($CONFIG['http_received_header_encrypt']) {
+ $http_header .= rcmail_encrypt_header($hostname);
+ if ($host != $hostname)
+ $http_header .= ' ('. rcmail_encrypt_header($host) . ')';
+ } else {
+ $http_header .= (($host != $hostname) ? $hostname : '[' . $host . ']');
+ if ($host != $hostname)
+ $http_header .= ' (['. $host .'])';
+ }
+ $http_header .= $nldlm . ' via ';
+ }
+ $host = $_SERVER['REMOTE_ADDR'];
+ $hostname = gethostbyaddr($host);
+ if ($CONFIG['http_received_header_encrypt']) {
+ $http_header .= rcmail_encrypt_header($hostname);
+ if ($host != $hostname)
+ $http_header .= ' ('. rcmail_encrypt_header($host) . ')';
+ } else {
+ $http_header .= (($host != $hostname) ? $hostname : '[' . $host . ']');
+ if ($host != $hostname)
+ $http_header .= ' (['. $host .'])';
+ }
+ // BY
+ $http_header .= $nldlm . 'by ' . $_SERVER['HTTP_HOST'];
+ // WITH
+ $http_header .= $nldlm . 'with HTTP (' . $_SERVER['SERVER_PROTOCOL'] .
+ ' '.$_SERVER['REQUEST_METHOD'] . '); ' . date('r');
+ $http_header = wordwrap($http_header, 69, $nldlm);
+
+ $headers['Received'] = $http_header;
+}
+
+$headers['Date'] = rcmail_user_date();
+$headers['From'] = rcube_charset_convert($from_string, RCMAIL_CHARSET, $message_charset);
+$headers['To'] = $mailto;