Bluemoon Posted December 22, 2011 Share Posted December 22, 2011 I'm trying to edit a script's notification email because the generated email doesn't have any line breaks or paragraphs and is three sentences all squished together. I've tried numerous attempts without any success and am hoping that a guru here might save me some time and frustration. $mailMessage = __("Greetings from My Site! You received a new message from", "name")." ".$sendfrom.", ".__("You can read the message at", "name").": ".$this->pageURL; I want a line break after "Greetings from My Site!" It would be nice to have a line break after "You received a new message from ___." Right now, the email looks like this: "Greetings from My Site! You received a new message from (name). You can read the message at (link)." Anyone know the best way to achieve this? It seems so simple but alludes me. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/ Share on other sites More sharing options...
Pikachu2000 Posted December 22, 2011 Share Posted December 22, 2011 Text emails use line breaks, not html <br> or <p> tags. Try using \r\n where you need a line break. Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1300595 Share on other sites More sharing options...
Bluemoon Posted December 22, 2011 Author Share Posted December 22, 2011 Thanks for your quick response. That makes sense. However, I'm not sure the correct way to implement it. I tried this and it didn't work: $mailMessage = __("Greetings from name!", "scriptname")."\r\n" __("You received a new message from", "scriptname.")." ".$sendfrom.". ".__("You can read the message at this link", "scriptname").": ".$this->pageURL; This is very confusing code to me. Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1300607 Share on other sites More sharing options...
Pikachu2000 Posted December 22, 2011 Share Posted December 22, 2011 Is this part of another application or a templating system? Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1300620 Share on other sites More sharing options...
Bluemoon Posted December 23, 2011 Author Share Posted December 23, 2011 It's a free plugin for WordPress. I'm usually able to figure things out on my own but this has me baffled. I tried this: $mailMessage = __("Greetings from My Site! \n \n You received a new message from", "name" \n \n)." ".$sendfrom.", ".__("You can read the message at", "name").": ".$this->pageURL; That didn't work. Do you know how to code the \n \n in this context? Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1300741 Share on other sites More sharing options...
scootstah Posted December 24, 2011 Share Posted December 24, 2011 Try \r\n. Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1301110 Share on other sites More sharing options...
Bluemoon Posted December 24, 2011 Author Share Posted December 24, 2011 Should \r\n be in quotes and/or parenthesis? I'm not sure how to code it properly. Would it look like this? mailMessage = __("Greetings from My Site! \r\n.." Or this: mailMessage = __("Greetings from My Site! "\r\n".." And would this look like: You received a new message from", "name" \r\n)." or this: You received a new message from", "name" "\r\n")." Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1301164 Share on other sites More sharing options...
jotorres1 Posted January 30, 2012 Share Posted January 30, 2012 Try escaping \\r\\n. Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1312602 Share on other sites More sharing options...
Bluemoon Posted January 30, 2012 Author Share Posted January 30, 2012 Thanks! This has actually been resolved and I see that I can mark it as such to close it. I just needed to change the declaration from text to HTML and then I was able to add regular <br> breaks where I wanted it. Worked like a charm. Quote Link to comment https://forums.phpfreaks.com/topic/253704-trying-to-add-line-breaks-such-as-or-in-a-snippet-without-success/#findComment-1312605 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.