Ver Mensaje Individual
  #16 (permalink)  
Antiguo 04/10/2008, 15:52
Avatar de pateketrueke
pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Método definitivo para mandar correos con PHPMailer que sí lleguen a Hotma

después de investigar un rato...

Enlace: http://www.webcheatsheet.com/PHP/sen...attachment.php


escribí una pequeña implementación de mail() y la probé en el mismo servidor (000webhost) solo que un sitio es a) tetl.site90.net (sin dominio propio) y el otro b) guardalo.com (en el que trabajo)

NOTA: yo no compre ni configuré el dominio b) .. ignoro el detalle de porque si funciona ahi, pues


a) envía correctamente a gmail, pero llega a los no deseados de hotmail
b) completamente perfecto en ambos!! (sin phpmailer)



de hecho, esta misma función la diseñe para adjuntar archivos... y sirvió!!

quizá no sirva a todos, pero es otra alternativa de PHP

Código PHP:
/**
 * (opciones[, adjuntos[, html?]])
 *
 * Envia un email usando la funcion nativa de PHP
 */
function mailto($test = array(), $add = array(), $html false)
{
    
//
    
$test array_merge(array(
            
'to' => null,
            
'from' => null,
            
'reply' => null,
            
'subject' => null,
            
'content' => null
    
), $test);
    
    
// en sus marcas!
    
$head = array(
            
"to: $test[to]",
            
'X-Mailer: PHP/'.phpversion(),
            
'MIME-version: 1.0'
    
);
    
    
$hash md5(uniqid('PHP'));
    
$mime $html'html''plain';
    
$content = !$html?  // limpiamos??
            
strip_tags($test['content']): $test['content'];
    
    if (isset(
$test['from']))
    { 
// origen..
        
$head[] = "from: $test[from]";
    }
    if (isset(
$test['reply']))
    {
// respuesta?
        
$head[] = "reply-to: $test[reply]";
    }
    
    
// header mixto...
    
$head[] = 'content-type: multipart/mixed; boundary="mix-'.$hash.'"';
    
    
// body mixto...
    
$body[] = "--mix-$hash";
    
$body[] = 'content-Type: multipart/alternative; boundary="alt-'.$hash.'"';
    
    
$body[] = "--alt-$hash";
    
$body[] = 'content-type: text/'.$mime.'; charset="iso-8859-1"';
    
$body[] = 'content-transfer-encoding: 7bit';
    
    
$body[] = null// xS
    
$body[] = $content;
    
$body[] = null;
    
    
$body[] = "--alt-$hash--";
    
    if (!empty(
$add) && is_array($add))
    {
        foreach (
$add as $key => $val)
        { 
// adjuntamos...!
            
$file is_numeric($key)? $val$key;
            
$key = !is_numeric($key)? $valnull;
            
            if (
is_file($file))
            {
                
$name is_file($file)? basename($file): urlencode($file);
                
$mime // establecemos tipo MIME... ?
                        
preg_match('/^[a-z]+\/[a-z0-9\+-]+$/i'$key)?
                        
$key'application/octet-stream';

                
$body[]="--mix-$hash";
                
$body[] = 'content-type: '.$mime.'; name="'.$name.'"';
                
$body[] = 'content-transfer-encoding: base64';
                
$body[] = 'content-disposition: attachment';

                
$body[]= null;
                
$body[]= // agregamos correctamente?
                        
chunk_split(base64_encode(file_get_contents($file)));
                
$body[]= null;
            }
        }
    }
    
$body[] = "--mix-$hash--";
    
    if (
mail($test['to'], $test['subject'], join("\n"$body), join("\n"$head)))
    { 
// ... ok!?
        
return true;
    }


ejemplo:
Código PHP:
$conf['to'] = '[email protected]';
$conf['from'] = '[email protected]';
$conf['subject'] = 'hola mundo!!!';
$conf['content'] = 'probando mail() de <b>PHP</b>';

$files[] = __FILE__//  este script!
$files['foo/bar/candy.txt'] = 'mime/type';

if (
mailto($conf$filestrue))
{
 
// ok


suerte!!!
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Última edición por pateketrueke; 04/10/2008 a las 17:04