Ver Mensaje Individual
  #15 (permalink)  
Antiguo 24/06/2009, 03:53
una_xikilla
 
Fecha de Ingreso: agosto-2008
Mensajes: 161
Antigüedad: 15 años, 8 meses
Puntos: 0
Respuesta: Error con phpmailer y gmail

Código PHP:
function MsgHTML($message,$basedir='') {
    
preg_match_all("/(src|background)=\"(.*)\"/Ui"$message$images);
    if(isset(
$images[2])) {
      foreach(
$images[2] as $i => $url) {
        
// do not change urls for absolute images (thanks to corvuscorax)
        
if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) {
          
$filename basename($url);
          
$directory dirname($url);
          (
$directory == '.')?$directory='':'';
          
$cid 'cid:' md5($filename);
          
$fileParts split("\."$filename);
          
$ext $fileParts[1];
          
$mimeType $this->_mime_types($ext);
          if ( 
strlen($basedir) > && substr($basedir,-1) != '/') { $basedir .= '/'; }
          if ( 
strlen($directory) > && substr($basedir,-1) != '/') { $directory .= '/'; }
          
$this->AddEmbeddedImage($basedir.$directory.$filenamemd5($filename), $filename'base64'$mimeType);
          if ( 
$this->AddEmbeddedImage($basedir.$directory.$filenamemd5($filename), $filename'base64',$mimeType) ) {
            
$message preg_replace("/".$images[1][$i]."=\"".preg_quote($url'/')."\"/Ui"$images[1][$i]."=\"".$cid."\""$message);
          }
        }
      }
    }
    
$this->IsHTML(true);
    
$this->Body $message;
    
$textMsg trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
    if ( !empty(
$textMsg) && empty($this->AltBody) ) {
      
$this->AltBody $textMsg;
    }
    if ( empty(
$this->AltBody) ) {
      
$this->AltBody 'To view this email message, open the email in with HTML compatibility!' "\n\n";
    }
  }

 function 
_mime_types($ext '') {
    
$mimes = array(
      
'hqx'  =>  'application/mac-binhex40',
      
'cpt'   =>  'application/mac-compactpro',
      
'doc'   =>  'application/msword',
      
'bin'   =>  'application/macbinary',
      
'dms'   =>  'application/octet-stream',
      
'lha'   =>  'application/octet-stream',
      
'lzh'   =>  'application/octet-stream',
      
'exe'   =>  'application/octet-stream',
      
'class' =>  'application/octet-stream',
      
'psd'   =>  'application/octet-stream',
      
'so'    =>  'application/octet-stream',
      
'sea'   =>  'application/octet-stream',
      
'dll'   =>  'application/octet-stream',
      
'oda'   =>  'application/oda',
      
'pdf'   =>  'application/pdf',
      
'ai'    =>  'application/postscript',
      
'eps'   =>  'application/postscript',
      
'ps'    =>  'application/postscript',
      
'smi'   =>  'application/smil',
      
'smil'  =>  'application/smil',
      
'mif'   =>  'application/vnd.mif',
      
'xls'   =>  'application/vnd.ms-excel',
      
'ppt'   =>  'application/vnd.ms-powerpoint',
      
'wbxml' =>  'application/vnd.wap.wbxml',
      
'wmlc'  =>  'application/vnd.wap.wmlc',
      
'dcr'   =>  'application/x-director',
      
'dir'   =>  'application/x-director',
      
'dxr'   =>  'application/x-director',
      
'dvi'   =>  'application/x-dvi',
      
'gtar'  =>  'application/x-gtar',
      
'php'   =>  'application/x-httpd-php',
      
'php4'  =>  'application/x-httpd-php',
      
'php3'  =>  'application/x-httpd-php',
      
'phtml' =>  'application/x-httpd-php',
      
'phps'  =>  'application/x-httpd-php-source',
      
'js'    =>  'application/x-javascript',
      
'swf'   =>  'application/x-shockwave-flash',
      
'sit'   =>  'application/x-stuffit',
      
'tar'   =>  'application/x-tar',
      
'tgz'   =>  'application/x-tar',
      
'xhtml' =>  'application/xhtml+xml',
      
'xht'   =>  'application/xhtml+xml',
      
'zip'   =>  'application/zip',
      
'mid'   =>  'audio/midi',
      
'midi'  =>  'audio/midi',
      
'mpga'  =>  'audio/mpeg',
      
'mp2'   =>  'audio/mpeg',
      
'mp3'   =>  'audio/mpeg',
      
'aif'   =>  'audio/x-aiff',
      
'aiff'  =>  'audio/x-aiff',
      
'aifc'  =>  'audio/x-aiff',
      
'ram'   =>  'audio/x-pn-realaudio',
      
'rm'    =>  'audio/x-pn-realaudio',
      
'rpm'   =>  'audio/x-pn-realaudio-plugin',
      
'ra'    =>  'audio/x-realaudio',
      
'rv'    =>  'video/vnd.rn-realvideo',
      
'wav'   =>  'audio/x-wav',
      
'bmp'   =>  'image/bmp',
      
'gif'   =>  'image/gif',
      
'jpeg'  =>  'image/jpeg',
      
'jpg'   =>  'image/jpeg',
      
'jpe'   =>  'image/jpeg',
      
'png'   =>  'image/png',
      
'tiff'  =>  'image/tiff',
      
'tif'   =>  'image/tiff',
      
'css'   =>  'text/css',
      
'html'  =>  'text/html',
      
'htm'   =>  'text/html',
      
'shtml' =>  'text/html',
      
'txt'   =>  'text/plain',
      
'text'  =>  'text/plain',
      
'log'   =>  'text/plain',
      
'rtx'   =>  'text/richtext',
      
'rtf'   =>  'text/rtf',
      
'xml'   =>  'text/xml',
      
'xsl'   =>  'text/xml',
      
'mpeg'  =>  'video/mpeg',
      
'mpg'   =>  'video/mpeg',
      
'mpe'   =>  'video/mpeg',
      
'qt'    =>  'video/quicktime',
      
'mov'   =>  'video/quicktime',
      
'avi'   =>  'video/x-msvideo',
      
'movie' =>  'video/x-sgi-movie',
      
'doc'   =>  'application/msword',
      
'word'  =>  'application/msword',
      
'xl'    =>  'application/excel',
      
'eml'   =>  'message/rfc822'
    
);
    return ( ! isset(
$mimes[strtolower($ext)])) ? 'application/octet-stream' $mimes[strtolower($ext)];
  }

  function 
set $name$value '' ) {
    if ( isset(
$this->$name) ) {
      
$this->$name $value;
    } else {
      
$this->SetError('Cannot set or reset variable ' $name);
      return 
false;
    }
  }

  function 
getFile($filename) {
    
$return '';
    if (
$fp fopen($filename'rb')) {
      while (!
feof($fp)) {
        
$return .= fread($fp1024);
      }
      
fclose($fp);
      return 
$return;
    } else {
      return 
false;
    }
  }

 function 
SecureHeader($str) {
    
$str trim($str);
    
$str str_replace("\r"""$str);
    
$str str_replace("\n"""$str);
    return 
$str;
  }

 function 
Sign($key_filename$key_pass) {
    
$this->sign_key_file $key_filename;
    
$this->sign_key_pass $key_pass;
  }

}

?>