Jump to content
modifiedcontent

Format messages for WireMail

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?

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mithlesh
      Hi there,
      My form is not getting submitted, it is showing:
      Unable to verify successful email delivery of this form submission.
      Attaching for your reference as well: 

      In the Backend, it is showing Connection timed out with smtp.gmail.com
      Pl guide me how to resolve that
    • By abdulqayyum
      hello processwire community,
      i am using LoginRegister module for front-end user registration. i am facing an issue verification email not receiving while WireMailSmtp is working perfectly and user receives message
      "Thank you, a confirmation code has been emailed to you. When you receive the email, click the link it contains, or paste the confirmation code below."
      received this message in front-end but does not receive any email relevant it.
      please help me in this case how i can solve it.
      Please check screen shots for SMTP test and message which receives user.
      Thanks AbdulQayyum,

      First screenshot SMTP test message, second when user receives message after clicking register button.
    • By rafaoski
      Hi everyone ...
      Generally, this is about the new mailHTML() function that does not work correctly on processwire 3.0.110
      https://github.com/processwire/processwire/blob/dev/wire/core/WireMailTools.php#L291
      https://processwire.com/api/ref/mail/mail-h-t-m-l/
      I do not know if I'm making a mistake trying to send an e-mail or if it's a bug in the core
      This is my code:
      <?php
      // $m = $mail->new(); // option A
      // $m = new WireMail(); // option B
         $m = wireMail(); // option C
         $m->mailHTML('alex@gmail.com', 'Hello', '<html><body><h1>Message Body</h1></body></html>');
         $m->send();
      ?>


      Details from Tracy Debugger
      SERVER DETAILS
      ProcessWire: 3.0.110
      PHP: 7.2.8
      Webserver: Apache/2.4.34 (Unix)
      MySQL: 10.1.34-MariaDB
      SERVER SETTINGS
      allow_url_fopen: 1
      max_execution_time: 120 (changeable)
      max_input_nesting_level: 64
      max_input_time: 60
      max_input_vars: 1000
      memory_limit: 256M
      post_max_size: 8M
      upload_max_filesize: 20M
      xdebug:
      xdebug.max_nesting_level:
      mod_rewrite: 1
      mod_security: *confirmed off
      GD: 2.2.5
      GIF: 1
      JPG: 1
      PNG: 1
      EXIF Support:
      FreeType: 1
      Imagick Extension:

      MODULE DETAILS
      TracyDebugger: 4.11.13
    • By rareyush
      I am using new processwire and I am receiving this error in my _func.php
       
      Parse Error: syntax error, unexpected 'return' (T_RETURN) Parse Error: syntax error, unexpected '$out' processwire anyone knows anything ??
×
×
  • Create New...