This page is no longer updated

We've left it here for reference. Find Out More.

PlanetHITOP

Notify Plugin

Adding Line Breaks

Sometimes with emails it is useful to have them sent in a standard format. Let's suppose you would like your email text to be formated like this:

Email message goes at the top.

Sender's email address: email.address@theiremail.invalid
Sent via the Planet Hitop email form

Pretty simple idea.

The message itself will get line breaks automatically if the user has used the return key in the textarea but how do we add the bits at the bottom?

Notify doesn't make this particularly obvious, but it can be done.

What we do is create a variable with the message in it, and use \n to represent a line break. So our message would look like this, with ${form_message} being the contents of our text area.

<@set name="message" value="${form_message}\n\nSender's email address: ${form_email}\nSent via the Planet Hitop email form">

We then use this variable in the @notify.email and mung it so that the \n is replaced by something that the command will interpret as a line break. To do this, we replace \n with &0A. So our @notify.email command will look like this:

<@notify.email to="myemail@example.com" from="${form_email}" subject="Email Form Message" message="${message:replace('\n','%0A'):UNESCAPEURL()}">


<back | top^ | next>

Planet Bods NetworkSites in the network