How to break lines when sending an email?

2

How do I break lines in an email that will be sent via PHP ?

  

If I use <br/> it works only if the email arrives in the spam box.

Part of the PHP code:

if(count($errors) == 0){
    $user = get_userdata( $status );
    $user->set_role('commentator_commenter');
    $from = get_option('admin_email');  
    $headers = __( 'De', 'commentator' ).' '.$from . "</br>";  
    $subject = __( 'Registrado com sucesso', 'commentator' );
    $msg = __( 'Você foi registrado com sucesso!<br/>', 'commentator' ).__( 'Seus dados:<br/>', 'commentator' ).__( 'Usuário:', 'commentator' ).$username.__( '<br/>Senha:', 'commentator' ).$password;
    add_filter( 'wp_mail_content_type', 'set_html_content_type' );
    wp_mail( $email, $subject, $msg, $headers );
    remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
    $arr = array(
        'message' => __( 'Registro com sucesso, verifique em seu e-mail a sua senha', 'commentator' )
    );
}
    
asked by anonymous 08.07.2014 / 02:37

3 answers

3

It is not because of the <br> that is in the spam box.

The line break depends on the content-type that you are using when sending the email.

You can use Content-Type: text/plain; charset=utf-8 so you do not have these problems.

Or you can do this:

add_filter('wp_mail_content_type',create_function('', 'return "text/plain"; '));

Font

    
08.07.2014 / 18:18
2

If you are using text message sending, you can use the following:

//...
$msg = __( 'Você foi registrado com sucesso!', 'commentator' ) 
    . "\n" . __( 'Seus dados:', 'commentator' )
    . "\n" .__( 'Usuário:', 'commentator' ). $username
    . "\n" . __( 'Senha:', 'commentator' ). $password;
    
08.07.2014 / 15:43
0

You can break lines using \n , I do not know if this will get you out of the spam box, because this is a lot more complex than more or less tags in the message body.

    
08.07.2014 / 02:59