• I’ve been trying to use all the source that can possibly help my problem but it’s just not working well.

    and this is my code:

    $subject = 'Pendaftaran Paytren (Daftar-Paytren.net)';
    $emaile = 'yukdaftarpaytren@gmail.com';
    $message = 'Ada yang daftar<br/>Nama Lengkap : '.$nama.'<br/>Tempat Lahir : '.$tempatlahir.'<br/>Tanggal Lahir : '.$tanggallahir.'<br/>Jenis Kelamin : '.$jeniskelamin.'<br/>Negara : '.$negara.'<br/>Kota Tampat Tinggal : '.$kota.'<br/>Nomor HP : '.$telp.'<br/>Email : '.$email.'<br/>Username : '.$username.'<br/>Pin BB : '.$bb.'<br/>WA : '.$wa;
    $headers = array('Content-Type: text/html; charset=UTF-8', 'From: Daftar-Paytren.net <yukdaftarpaytren@gmail.com>');                    
    
        if (wp_mail( $emaile, $subject, $message, $headers )){
            echo "success";
        }else {
            echo wp_mail( $emaile, $subject, $message, $headers );
        }

    and it was said success as if, but I wasn’t receive any mail in my inbox. but if I remove the headers ‘Content-type:’ thing, so the code will be:

    $subject = 'Pendaftaran Paytren (Daftar-Paytren.net)';
    $emaile = 'yukdaftarpaytren@gmail.com';
    $message = 'Ada yang daftar<br/>Nama Lengkap : '.$nama.'<br/>Tempat Lahir : '.$tempatlahir.'<br/>Tanggal Lahir : '.$tanggallahir.'<br/>Jenis Kelamin : '.$jeniskelamin.'<br/>Negara : '.$negara.'<br/>Kota Tampat Tinggal : '.$kota.'<br/>Nomor HP : '.$telp.'<br/>Email : '.$email.'<br/>Username : '.$username.'<br/>Pin BB : '.$bb.'<br/>WA : '.$wa;
    $headers = 'From: Daftar-Paytren.net <yukdaftarpaytren@gmail.com>' . "\r\n";                    
    
        if (wp_mail( $emaile, $subject, $message, $headers )){
            echo "success";
        }else {
            echo wp_mail( $emaile, $subject, $message, $headers );
        }

    and that’ll work and I receive the email but as plain text. I need to set the content type so the email can be read as well.

    and I also tried this, still nothing work.

    $headers[] = 'Content-Type: text/html; charset=UTF-8';
    $headers[] = 'From: Daftar-Paytren.net <yukdaftarpaytren@gmail.com>' . "\r\n";

    What is wrong with my code? please help me. and please ignore the language on that script.

    UPDATE

    if I used this code:

    add_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
    $emaile = 'yukdaftarpaytren@gmail.com';
    $subject = 'Pendaftaran Paytren (Daftar-Paytren.net)';
    $message = 'Ada yang daftar<br/>Nama Lengkap : '.$nama.'<br/>Tempat Lahir : '.$tempatlahir.'<br/>Tanggal Lahir : '.$tanggallahir.'<br/>Jenis Kelamin : '.$jeniskelamin.'<br/>Negara : '.$negara.'<br/>Kota Tampat Tinggal : '.$kota.'<br/>Nomor HP : '.$telp.'<br/>Email : '.$email.'<br/>Username : '.$username.'<br/>Pin BB : '.$bb.'<br/>WA : '.$wa;
    $headers = 'From: Daftar-Paytren.net <yukdaftarpaytren@gmail.com>' . "\r\n";                   
    
    if (wp_mail( $emaile, $subject, $message, $headers )){
                            echo "sukses";
    }else {
    echo wp_mail( $emaile, $subject, $message, $headers );
    }
    // Reset content-type to avoid conflicts -- https://core.trac.wordpress.org/ticket/23578
    remove_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
    
    function wpdocs_set_html_mail_content_type() {
        return 'text/html';
    } 

    The email was sent and I was receiving an inbox but, it is sending the subject as file attachment (.txt) with plain text as the content.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Some mail servers seem to send content as a redundant attachment. It’s beyond the ability of wp_mail() to do anything about that, it’s something about how the server itself is configured.

    The plain text would be because some other code is overriding yours. Try adding the filter with a large priority number so your callback has the final say. Don’t forget to use the same priority to remove the filter.

    If that doesn’t help, the mail server might be configured to only send plain text.

    Thread Starter x00001101

    (@x00001101)

    thank you for your reply, yeah seems like my other code is overriding this mail function. It was once succeeded sending Email.

    well then, I just have to do some searching mistakes.

    i will update soon, if this is solved. or maybe not at all.

    Thanks @bcworkz

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_mail() success sent when it is not using header ‘content-type:text/html’’ is closed to new replies.