- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
/*-------------------------------------------------------------------------*/
// ENCODE HEADERS - RFC2047
/*-------------------------------------------------------------------------*/
function encode_headers( $headers = array() )
{
$enc_headers = count($headers) ? $headers : $this->mail_headers;
foreach( $enc_headers as $header => $value)
{
$orig_value = $value;
preg_match_all( '/(\w*[\x80-\xFF]+\w*)/', $value, $matches );
foreach ($matches[1] as $match_value)
{
if( $header == 'From' OR $header == 'Content-Type' OR $header == 'Content-Disposition' )
{
// Either sendmail or the email servers don't like 'From' encoded...let's remove the board name
// and just move along, as email address cannot contain nasty characters themselves
$this->mail_headers[ $header ] = $orig_value;//$this->from;
$enc_headers[ $header ] = $orig_value;//$this->from;
continue 2;
}
$replacement = preg_replace_callback( '/([=_\?\x00-\x1F\x80-\xFF])/', create_function( '$match', 'return "=" . strtoupper( dechex( ord( "$match[1]" ) ) );' ), $match_value );
$value = str_replace( $match_value, $replacement, $value );
}
if( $orig_value != $value )
{
$value = '=?' . $this->char_set . '?Q?' . str_replace( " ", "=20", $value ) . '?=';
}
if( !count($headers) )
{
$this->mail_headers[ $header ] = $value;
}
else
{
$enc_headers[ $header ] = $value;
}
}
return $enc_headers;
}
Комментарии (0) RSS
Добавить комментарий