demlak
1
Hey… i’m using code like this and try to use linebreak in data->text. any idea? those tests did not work
$kirby->email([
'template' => 'email',
'from' => esc($site->email()),
'replyTo' => $data['email'],
'to' => esc($targetmail),
'subject' => '[' . esc($data['title']) . '] ' . esc($data['name']) . ' ' . esc($site->labelEmailSubject()->or('sent you a message from your contact form')),
'data' => [
'text' => 'test1' . '\\n' . 'test2' . '\\n\\l' . 'test3' . '\n' . 'test4' . '\n\l' . 'test5',
'sender' => esc($data['name'])
]
]);
Could you try \n
in double quotes like: "\n"
'data' => [
'text' => 'test1' . "\n" . 'test2' . "\n\l" . 'test3' . "\n" . 'test4' . "\n\l" . 'test5',
'sender' => esc($data['name'])
]
demlak
3
hey…
thx a lot…
but well… now i see it’s more complicated as thought…
in text-only view, there is a linebreak by using ‘"\n"’… but in html view it’s not…
when using "<br>"
instead, results in the opposite…
i’m confused about the correct solution for getting linebreaks in such multipart-messages that are created by kirby->email()
Why don’t you create separate fields per line, then you can add your line breaks inside the templates.
demlak
5
i don’t get it… could you please explain in other words and/or in more detail?
What I mean is
'text1' => 'test1',
'text2' => 'test2',
'text3' => 'test3'
'sender' => esc($data['name'])
Then add linebreaks after each field as “\n” in your text template, <br>
in your HTML template.
demlak
7
thx… this would help in my specific case… but seems to me not realy a solution for multiline text in fields.
Any idea for them? we use an inputfield where people could write in multiple lines.
edit:
nevermind… i think i have to write a solution to split the multiline string to reformat it for html-mails…
edit2:
simple nl2br()
1 Like