Advertisement
Guest User

Untitled

a guest
Apr 24th, 2013
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. <?php
  2. // @see http://api.drupal.org/api/drupal/6
  3. function drupal_truncate_bytes($string, $len) {
  4.   if (strlen($string) <= $len) {
  5.     return $string;
  6.   }
  7.   if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
  8.     return substr($string, 0, $len);
  9.   }
  10.   while (--$len >= 0 && ord($string[$len]) >= 0x80 && ord($string[$len]) < 0xC0) {
  11.   }
  12.   return substr($string, 0, $len);
  13. }
  14.  
  15. function mime_header_encode($string) {
  16.   if (preg_match('/[^\x20-\x7E]/', $string)) {
  17.     $chunk_size = 47; // floor((75 - strlen("=?UTF-8?B??=")) * 0.75);
  18.     $len = strlen($string);
  19.     $output = '';
  20.     while ($len > 0) {
  21.       $chunk = drupal_truncate_bytes($string, $chunk_size);
  22.       $output .= ' =?UTF-8?B?' . base64_encode($chunk) . "?=\n";
  23.       $c = strlen($chunk);
  24.       $string = substr($string, $c);
  25.       $len -= $c;
  26.     }
  27.     return trim($output);
  28.   }
  29.   return $string;
  30. }
  31.  
  32.  
  33. echo "I'm running";
  34.  
  35. $message = array(
  36.   'to' => 'YOUREMAILHERE@example.com',
  37.   'subject' => 'Hello world',
  38. );
  39.  
  40. mail($message['to'], mime_header_encode($message['subject']), 'Hello world httpd sendmail.');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement