Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/01/2013, 14:43
MarceFX
 
Fecha de Ingreso: febrero-2012
Ubicación: Granada/Madrid
Mensajes: 183
Antigüedad: 12 años, 3 meses
Puntos: 8
Problema al dar formato HTML a emails desde PHP

Hola,

Estoy usando un plugin en Wordpress para el formulario de contacto. Quiero que el email llegue en HTML, pero falla algo y aparece en un formato raro. No pilla bien los enlaces.

En el código tengo esto:

Código HTML:
Mensaje enviado desde <a href="http://vendoandroid.com" target="_blank"><strong>VendoAndroid.com</strong></a> 
Pero en el email llega así:



Pilla el enlace, pero corta el código. El PHP que tengo es este:

Código PHP:
// Types
                
if ($field['type']) :
                    switch (
$field['type']) :
                        case 
"email" :
                            if(!
is_email($posted[$field['name']])) $error .= __('<li>Dirección de email incorrecta</li>','jigowatt');
                            
//$headers = "From: ".$posted[$field['name']]."\r\n\\";
                            //$headers .= "Reply-To: [email protected]\r\n\\";
                            // To send HTML mail, the Content-type header must be set
                            
$headers  'MIME-Version: 1.0' "\r\n";
                            
$headers .= 'Content-type: text/html; charset=utf-8' "\r\n";
                            
                            
// Additional headers. Añadido: Para que no llegue como SPAM, el mail tiene que ser el mismo que tenemos
                            // en el plugin WP SMTP para que autentique
                            
$mail_interesado $posted[$field['name']];
                            
$headers .= 'From: VendoAndroid <[email protected]>' "\r\n";
                            
$headers .= 'Reply-to: '.$mail_interesado.'' "\r\n";
                            
                            
$address get_the_author_meta('user_email'$author_id);
                            
                        break;
                    endswitch;
                endif;
            endif;

        endforeach;

        
$posted array_map('clean_var'$posted);

        
// Captcha
        
if ( isset($_POST['jigowatt_image_captcha']) ) :

            if (isset(
$_POST['jigowatt_image_captcha'])) :
                
$posted_verify   trim(stripslashes($_POST['jigowatt_image_captcha']));
                   
$posted_verify   md5($posted_verify);
               else :
                   
$posted_verify '';
               endif;

            
$session_verify $_SESSION['verify'];

            if (empty(
$session_verify)) $session_verify $_COOKIE['verify'];

            if(
$session_verify != $posted_verify) {
                
$error .= __('<li>Código antispam incorrecto</li>','jigowatt');
            }

        endif;
        
        
        if(
$error != '') {
            echo 
'<div class="error_message">'.__('¡Atención! Algo falla:','jigowatt').'';
            echo 
'<ul class="error_messages">' $error '</ul>';
            echo 
'</div>';

        } else {

        
$post_tmp get_post($_REQUEST['current_post_id']);
        
$author_id $post_tmp->post_author;
        
$address get_the_author_meta('user_email'$author_id);

        
$e_subject __('Alguien se ha interesado por tu anuncio en VendoAndroid','jigowatt');

        
// Advanced Configuration Option.
        // You can change this if you feel that you need to.
        // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.

        
$msg  __('¡Hola! Un usuario de VendoAndroid se ha interesado en tu anuncio:'). PHP_EOL PHP_EOL;
        
$msg .= __('<a href="'.get_permalink($post_tmp).'">Título:'.get_the_title($post_tmp).' target="_blank"</a>') . PHP_EOL PHP_EOL;
        
$msg .= implode(PHP_EOL$comments) . PHP_EOL PHP_EOL;
        
$msg .= "-------------------------------------------------------------------------------------------\r\n";
        
$msg .= 'Mensaje enviado desde <a href="http://vendoandroid.com" target="_blank"><strong>VendoAndroid.com</strong></a>';

        
$msg wordwrap$msg70 ); 
Aunque en el header tengo esto:

Código PHP:
$headers  'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n"
El código del email muestra text/plain.

¿Alguna idea?

Gracias
__________________
¿Pensando en vender o comprar un Android? Pásate por VendoAndroid y échame una mano :-)