Skip to content

Instantly share code, notes, and snippets.

@wujku
Forked from Robbert/message-id.php
Created October 30, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wujku/61acde16f37ebe6391eea61556c2a12e to your computer and use it in GitHub Desktop.
Save wujku/61acde16f37ebe6391eea61556c2a12e to your computer and use it in GitHub Desktop.
Message-ID generator in PHP for mail headers.
<?php
/**
* @see http://www.jwz.org/doc/mid.html
*/
function generateMessageID()
{
return sprintf(
"<%s.%s@%s>",
base_convert(microtime(), 10, 36),
base_convert(bin2hex(openssl_random_pseudo_bytes(8)), 16, 36),
$_SERVER['SERVER_NAME']
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment