Wordpress does not send email in html format

0

I have a small problem with the sending of emails in wordpress it turns out that it does not send email with plain text html content

In my function I have the following code which should work:

function confirmed_visited($post_author, $project_id){
        global $user_ID;


        $freelance_email = get_the_author_meta( 'user_email', $post_author );
        $freelance_display_name = get_the_author_meta( 'display_name', $post_author );
        $freelance_photo = get_the_author_meta( 'et_avatar_url', $post_author );
        $freelance_direction = get_the_author_meta( 'user_direccion', $post_author );
        $freelance_doc = get_the_author_meta( 'user_numero_doc', $post_author );
        $freelance_cel = get_the_author_meta( 'user_celular', $post_author );
        $freelance_tel = get_the_author_meta( 'user_telefono', $post_author );
        $freelance_city = get_the_author_meta( 'user_ciudad', $post_author );

        $user_email   = get_the_author_meta( 'user_email', $user_ID );
        $display_name   = get_the_author_meta( 'display_name', $user_ID );

        $project_ini     = get_post_meta( $project_id, 'fecha_inicio', true );

        $body = '<p>Hi '.$display_name.'</p>';


        $subject = __( "Thank you for submitting your bid.", ET_DOMAIN );

        $headers[] = 'From: ' . get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>' . "\r\n";
        $headers[] = "Content-type: text/html; charset=iso-8859-1";
        //Filtro para indicar que email debe ser enviado en modo HTML

        wp_mail($user_email, $subject, $body, $headers);

    }

However I receive the mail in this way <p>Hi Ethan Jesuan Salazar</p> For what I see does not format the html natively even make a class mailing to see if I could format it that way and nothing left the function of the class mailin:

public function wp_mail( $to, $subject, $content, $filter = array(), $headers = '' ) {
        if ( $headers == '' ) {

            // $headers = 'MIME-Version: 1.0' . "\r\n";
            // $headers.= 'Content-type: text/html; charset=utf-8' . "\r\n";
            $headers .= "From: " . get_option( 'blogname' ) . " < " . get_option( 'admin_email' ) . "> \r\n";
        }
        $headers = apply_filters( 'ae_mail_header_info', $headers );
        /**
         * site info url, name, admin email
         */
        $content = str_ireplace( '[site_url]', get_bloginfo( 'url' ), $content );
        $content = str_ireplace( '[blogname]', get_bloginfo( 'name' ), $content );
        $content = str_ireplace( '[admin_email]', get_option( 'admin_email' ), $content );

        if ( isset( $filter['user_id'] ) ) {
            if ( isset( $filter['active_link'] ) ) {
                $content = $this->filter_authentication_placeholder( $content, $filter['user_id'], $filter['active_link'] );
            } else {
                $content = $this->filter_authentication_placeholder( $content, $filter['user_id'] );
            }
        }
        if ( isset( $filter['post'] ) ) {

            // filter post placeholder
            $content = $this->filter_post_placeholder( $content, $filter['post'] );
        }
        $content = html_entity_decode( (string) $content, ENT_QUOTES, 'UTF-8' );
        $subject = html_entity_decode( (string) $subject, ENT_QUOTES, 'UTF-8' );

        //$content    = $this->get_mail_header() . $content . $this->get_mail_footer() ;
        add_filter( 'wp_mail_content_type', array(
            $this,
            'set_html_content_type'
        ) );
        $a = wp_mail( $to, $subject, $this->get_mail_header() . $content . $this->get_mail_footer(), $headers );
        remove_filter( 'wp_mail_content_type', array(
            $this,
            'set_html_content_type'
        ) );

        return $a;
    }

    function set_html_content_type() {
        return 'text/html';
    } 

This class does not send emails in html format, but in plain text

    
asked by vdjkelly 08.02.2018 в 00:03
source

0 answers