Support » Plugin: Contact Form 7 » Message do not keep line break

  • Resolved Patrice

    (@patricevigier)


    Hello,

    When we send a message, all the text from the text box is in one line instead of keeping line change.
    For example
    Line one
    Line two
    Line three

    will be received in the message like this:
    Line one Line two Line three

    How can I change this behavior?

    Thank you
    Patrice

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the website in question?

    Thread Starter Patrice

    (@patricevigier)

    Hello,
    Here it is
    http://www.vigierguitars.com
    Sincerely
    Patrice

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    See Setting up mail

    What email settings do you have in the Mail tab panel?

    Thread Starter Patrice

    (@patricevigier)

    Hello Takayuki,
    Thank you for your answer.
    I guess you mean in the Message body, here it is:

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"><head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                <title>Vigier contact form</title>
                <style>
                    body {
                        background-color: black !important;
                        color:#CCC;
                        font-size:14px !important;
                      /*  font-family: "lato", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif !important;*/
                        padding:20px;
                        min-height:400px;
                    }
                    h1 {
                        margin-left: 40px;
                    }
                </style>
        </head>
       <body contenteditable="true">
            <!-- Début image -->
            <img src="data:image/png;base64,
                 iVBORw0KGgoAAAANSUhEUgAAAMgAAAByCAYAAAAWCZ6NAAAACXBIWXMAAAsTAAAL
                 EwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAA
                 7AAAAABJRU5ErkJggg==" alt="Vigier Guitars">
    
                <!-- Fin image -->
                <br>
                <br>
                <b>De :</b> [your-name] - [your-email]<br>
                <b>Service :</b> [_raw_your-recipient]<br>
                <b>Sujet :</b> [sujet]<br>
                <br>
                <b>Message :</b><br>
                [your-message]<br>
                <br>
                <br>
                <b>Pièce jointe :</b> </br>[upload-file-248]
                <br>
                <br>
    This e-mail was sent from a contact form on zzzz (http://www.zzzzz.com) [_date] - [_time] - IP: [_remote_ip]
                </body></html>

    Use html is selected
    Thank you
    Patrice

    • This reply was modified 1 year, 1 month ago by Patrice.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    Replace it solely with the body part as:

    <img src="data:image/png;base64,
         iVBORw0KGgoAAAANSUhEUgAAAMgAAAByCAYAAAAWCZ6NAAAACXBIWXMAAAsTAAAL
         EwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAA
         7AAAAABJRU5ErkJggg==" alt="Vigier Guitars">
    
        <!-- Fin image -->
        <br>
        <br>
        <b>De :</b> [your-name] - [your-email]<br>
        <b>Service :</b> [_raw_your-recipient]<br>
        <b>Sujet :</b> [sujet]<br>
        <br>
        <b>Message :</b><br>
        [your-message]<br>
        <br>
        <br>
        <b>Pièce jointe :</b> </br>[upload-file-248]
        <br>
        <br>
    This e-mail was sent from a contact form on zzzz (http://www.zzzzz.com) [_date] - [_time] - IP: [_remote_ip]

    The header and footer parts are automatically generated.

    Thread Starter Patrice

    (@patricevigier)

    Hello,
    Thank you very much and sorry for the late reply.
    It works for the line break.
    But where do I put the css?

    <style>
                    body {
                        background-color: black !important;
                        color:#CCC;
                        font-size:14px !important;
                      /*  font-family: "lato", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif !important;*/
                        padding:20px;
                        min-height:400px;
                    }
                    h1 {
                        margin-left: 40px;
                    }
                </style>

    Thank you
    Patrice

    Thread Starter Patrice

    (@patricevigier)

    I try to leave the css on top but then margins are not good.

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    You can use the wpcf7_mail_html_header filter hook to replace the default header.

    Thread Starter Patrice

    (@patricevigier)

    Hello Takayuki,
    Thank you again for your answer.
    I try to override the mail.php function in functions.php but I do not have the knowledge to do it. So I did replace the function directly in mail.php, but I still have a margin problem, there are two line added before my message srart (with a logo)

    Do you have any idea why?

        private function htmlize($body) {
            if ($this->locale) {
                $lang_atts = sprintf(' %s', wpcf7_format_atts(array(
                    'dir' => wpcf7_is_rtl($this->locale) ? 'rtl' : 'ltr',
                    'lang' => str_replace('_', '-', $this->locale),
                        ))
                );
            } else {
                $lang_atts = '';
            }
    
            $header = apply_filters('wpcf7_mail_html_header', '
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>' . esc_html($this->get('subject', true)) . '</title>
    <style>
        body {
            background-color: black !important;
            color:#CCC;
            font-size:14px !important;
            padding:20px;
            min-height:400px;
             }
        h1 {
            margin-left: 40px;
            }
    </style>
    </head>
    <body>
    ', $this);
    
            $footer = apply_filters('wpcf7_mail_html_footer', '</body>
    </html>', $this);
    
            $html = $header . wpautop($body) . $footer;
            return $html;
        }

    Thank you in advance
    Patrice

    • This reply was modified 1 year, 1 month ago by Patrice.
    Thread Starter Patrice

    (@patricevigier)

    Hello,
    Can somebody help me override the mail.php in the functions.php ?
    Thank you
    Patrice

    Thread Starter Patrice

    (@patricevigier)

    The reason why I had a big margin on top of my e-mail after doing the modification of mail.php was the base64 image included in the email contact form (in WordPress).

    I did put the base64 image in the mail.php and it worked.

    So for those that are interested, my code is, starting around line 80:

    $header = apply_filters( 'wpcf7_mail_html_header',
    '<!doctype html>
    <html xmlns="http://www.w3.org/1999/xhtml"' . $lang_atts . '>
    <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
                <title>Vigier formulaire de contact</title>
                <style>
                    body {
                        background-color: black !important;
                        color:#CCC;
                        font-size:14px !important;
                        padding:20px;
                        min-height:400px;
                    }
                    h1 {
                        margin-left: 40px;
                    }
                </style>
    </head>
    
    <body contenteditable="true">
            <!-- Début image -->
            <img src="data:image/png;base64,
                 iVBORw0KGgoAAAANSUhEUgAAAMgAAAByCAYAAAAWCZ6NAAAACXBIWXMAAAsTAAAL
                 EwEAmpwYAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6JQAAgIMAAPn/AACA6QAA
                 ATSvYpY5xWWqGHtW+SFjsijJsj9EeTmF7REBJU2X9H3WgP1m6C37dEXQwJp9OULoJWx
                 EUww" alt="Vigier Guitars">
                <!-- end image -->
    ', $this );
    
    		$footer = apply_filters( 'wpcf7_mail_html_footer',
    			'</body>
    </html>', $this );
    Thread Starter Patrice

    (@patricevigier)

    Hello,
    How do I keep mail.php from being updated from CF7 update?
    I do not know how to override it in the function.php
    Can anybody help me?
    Thank you

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Message do not keep line break’ is closed to new replies.