Title: Additional Date header DATE_RFC2822
Last modified: August 21, 2016

---

# Additional Date header DATE_RFC2822

 *  [frenil75](https://wordpress.org/support/users/frenil75/)
 * (@frenil75)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/)
 * Where can I set additional header date:
    Date: $date
 * where
    $date = date(DATE_RFC2822);
 * (I also need to set Message-ID similary)
 * Regards,
    /Fredrik
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982358)
 * You don’t need to set Date and Message-ID as they are set by your mail server
   automatically.
 *  Thread Starter [frenil75](https://wordpress.org/support/users/frenil75/)
 * (@frenil75)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982390)
 * The web hosting service does not set it automatically and requires them to be
   set.
 * If I run their example, below, I can send mail to external gmail, but not via
   wordpress and cf7
 *     ```
       <?php
       // Data för mailet
       $sender = "noreply@mywordpressdomain.se";
       $sendername = "My page";
       $recipient = "mygmailadress@gmail.com";
       $recipientname = "My name";
       $subject = "Subject for the mail";
       $message = "mail content";
   
       // Generera datum och mailets id
       $date = date(DATE_RFC2822);
       $mid = "<" . sha1(microtime()) . "@" . $_SERVER['HTTP_HOST'] . ">";
   
       // Ställ in rätt kodningstyp
       mb_internal_encoding("UTF-8");
   
       // Rätt kodning för avsändare och mottagares namn
       $sendername = mb_encode_mimeheader($sendername);
       $recipientname = mb_encode_mimeheader($recipientname);
   
       // Sätt headers
       $headers =<<<EOT
       From: $sendername <$sender>
       Date: $date
       Message-ID: $mid
       MIME-Version: 1.0
       Content-Type: text/plain; charset="UTF-8"
       EOT;
   
       // Skicka mail
       $status = mb_send_mail("$recipientname <$recipient>", $subject, $message, $headers, "-f$sender");
       if(!$status) {
               echo "Mail kunde inte skickas.";
       }
       else {
               echo "Mail skickat!";
       }
       ?>
       ```
   
 *  Thread Starter [frenil75](https://wordpress.org/support/users/frenil75/)
 * (@frenil75)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982406)
 * If I add them to classes.php line 728
 *     ```
       $additionaldate = date(DATE_RFC2822);
       		$additionalmid = "<" . sha1(microtime()) . "@" . $_SERVER['HTTP_HOST'] . ">";
       		$headers .= "Date: ". $additionaldate ."\n";
       		$headers .= "Message-ID: ". $additionalmid . "\n";
       ```
   
 * it works, but is there a way to set them directly in Additional Header-area instead?(
   so that the will not be overwritten when upgrading the plugin?
 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982435)
 * They shouldn’t be set manually. Even when the MTA doesn’t set them, PHPMailer
   does. If you are using any mail-related plugin that avoid PHPMailer, try deactivating
   it.
 *  [boblet](https://wordpress.org/support/users/boblet/)
 * (@boblet)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982709)
 * There seems to be a conflict in the way the `date` header is set between wordpress/
   wp-settings.php#L43
 *     ```
       // WordPress calculates offsets from UTC.
       date_default_timezone_set( 'UTC' );
       ```
   
 * and wp-includes/class-phpmailer.php#L2671
 *     ```
       public static function rfcDate()
       {
       //Set the time zone to whatever the default is to avoid 500 errors
       //Will default to UTC if it's not set properly in php.ini
       date_default_timezone_set(@date_default_timezone_get());
       return date('D, j M Y H:i:s O');
       }
       ```
   
 * (I had `date` set to JST on server and in WP and php.ini, but still got UTC).
 * You can get around this by changing the line in wp-settings.php to your preferred
   timezone as per [http://project-syatiku.com/archives/191.html](http://project-syatiku.com/archives/191.html)
 * Possibly related:
 * [https://core.trac.wordpress.org/ticket/11665](https://core.trac.wordpress.org/ticket/11665)
   
   [https://core.trac.wordpress.org/ticket/11672](https://core.trac.wordpress.org/ticket/11672)
 * HTH
 *  [boblet](https://wordpress.org/support/users/boblet/)
 * (@boblet)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982710)
 * PS Changing `date_default_timezone_set()` breaks CF7’s `_date` and `_time` variables.
   Sigh.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Additional Date header DATE_RFC2822’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [boblet](https://wordpress.org/support/users/boblet/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/additional-date-header-date_rfc2822/#post-4982710)
 * Status: not resolved