Support » Plugins » Hacks » register_setting – textarea with line-breaks

  • Resolved Valentin


    Hey there,

    I’m scripting a plugIn which can submit a specific message to an email address.
    The mail text is specified in the back-end in a textarea.

    The problem I do have is:
    In the back-end textarea line-breaks are displayed correctly,
    (Simple as line-breaks, not as “
    ” tags or anything else, just a break)
    but in the mail the user receives the breaks are removed.

    Why is that?
    The functions I’m using are:

    register_setting( 'va_db_form_settings', 'va_db_form_mail_content' );
    To register the setting.

    $mail_text = get_option('va_db_form_mail_content');
    $mail_rec = get_option('va_db_form_mail');
    $mail_sender = "From: ".get_bloginfo('name')." < ".get_bloginfo('admin_email')." >\n";
    $mail_sender .= "Content-Type: text/html\n";
    $mail_sender .= "Content-Transfer-Encoding: 8bit\n";
    $message = $mail_text;
    mail($mail_rec, $mail_sub, $message, $mail_sender);

    To send the mail.

    Appreciate your help!


Viewing 3 replies - 1 through 3 (of 3 total)
  • Try it without the line: $mail_sender .= “Content-Type: text/html\n”;

    Or (in case you want to send is as html) transfer $message to html and the Content-Type can stay as it is now (text/html).

    $message = str_replace(array("\r\n", "\n", "\r"), "<br />", $mail_text);


    Yeah thought of that myself in the end.
    Pretty dump I didn’t earlier.

    $message = nl2br($mail_text);

    Thanks a lot anyway! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘register_setting – textarea with line-breaks’ is closed to new replies.