Jump to content

Format messages for WireMail


modifiedcontent
 Share

Recommended Posts

How should messages for Wire or $mail->send() be formatted? There is some information here; you can send text and html versions, but there are no examples how to format those.

/n or /r/n etc. is ignored for the text version. What syntax should be used to get line breaks in the email?

For the html version, it would be nice if you could pull that from a field. For most emails you would need to be able to insert the recipient's name and other data. PHP variables don't work in field content.

Are there other ways to achieve this; replace a tag in the field body with data from php script in the template? Maybe with Hanna Code? Or is that what RuntimeMarkupField is for?

Link to comment
Share on other sites

6 minutes ago, modifiedcontent said:

For the html version, it would be nice if you could pull that from a field, but in most emails you would need to be able to insert the recipients name and other things. PHP variables don't work in field content.

WireMail is there to send mails and not to care about what it's sending or how that markup is created. You can create the html markup, which should be sent, in whichever way you desire. It could be a page being rendered, there's wirePopulateStringTags() or you could stitch together strings in php. 

9 minutes ago, modifiedcontent said:

/n or /r/n etc. is ignored for the text version.

That doesn't sound right. 

  • Like 2
Link to comment
Share on other sites

Quote

That doesn't sound right.

/n/r? /n/n/r? /r/n/r? Either way, I use an obscure email client - Claws Mail - that often produces odd results. It is supposed to be a text-based client though.

Thanks for the wirePopulateStringTags() suggestion! Looking into that one now...

Edit: wirePopulateStringTags() works painless, perfect for this purpose. If you put something like this in any regular field...:

Quote

Hello {tagname},

Here is {anothertag} for you

...and this in your template...:

$fullname = 'Hannah';
echo wirePopulateStringTags($page->body,['tagname' => $fullname, 'anothertag' => 'more inserted content']); 

...it just works.

Link to comment
Share on other sites

5 hours ago, modifiedcontent said:

I use an obscure email client - Claws Mail - that often produces odd results.

I'd really rather suspect that then WireMail not sending newlines. Still could be a bug in one of the 3.0 additions to wiremail.

  • Like 1
Link to comment
Share on other sites

Whatever field settings I used - with/without HTML Entity Encoder, CKEDitor/Textarea, txt/markup - I kept getting '&lt;p&gt;' or '<p>' in my emails. I finally got it working by using no Text Formatters + CKEditor + Markup and then put strip_tags() around the field in the template.

Not sure what that means and I may have missed a correct way to do it. I ran out of time/patience. This works for now.

  • Like 2
Link to comment
Share on other sites

On 12/03/2017 at 6:26 PM, modifiedcontent said:

Whatever field settings I used - with/without HTML Entity Encoder, CKEDitor/Textarea, txt/markup - I kept getting '&lt;p&gt;' or '<p>' in my emails. I finally got it working by using no Text Formatters + CKEditor + Markup and then put strip_tags() around the field in the template.

Not sure what that means and I may have missed a correct way to do it. I ran out of time/patience. This works for now.

Getting the same thing here, I followed this guide:

...everything works but I receive plain text emails with HTML tags in them. I'll try what you did see if I have some success. Thanks.

 

--EDIT--

Got it working now:

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...