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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By fruid
      What's wrong with my code? It just won't send emails. It worked before when not using wiremailSMTP but now it stops. This is used in a contact form.
      It has to be the code because when I run a test in the module, it works fine and the email reaches me.
      Even the Promailer-Newsletters using WireMail SMTP work fine now.
      Even when I put some debug code on the template to be send to me via email with every email, that email reaches me. 
      But somehow the email in question, send with contact form does not.
      BTW if-condition works fine cause redirection works as well.
      Here's my code:
      if (isset($_POST['sendform']) && $captcha->verifyResponse() === true) :     $givenname = $input->post->text('givenname');      $familyname = $input->post->text('familyname');      $fullname = $givenname.' '.$familyname;     $fullname = ucwords($fullname);     $email = $input->post->email('emailaddress');      $subject = $input->post->text('subject');      $message = $input->post->text('message');      $m = wireMail();     $m->to('myemail@mydomain.com', 'my Name');     $m->from($email, $fullname);     $m->subject($subject);     $m->body($message);     $m->send();     $session->redirect($pages->get("/kontakt/danke/")->url); endif; I recently installed a SSL certificate on the webserver, but that should be irrelevant, right?
      Further settings:
      port: 587
      Allow Connection without Authentication: no
      SMTP User and SMTP Password provided
      Use Start-TLS: no
      TLS Crypto method: 1.2
      Use SSL: no
      Allow self signed certificated: no
      Thanks for help!
       
    • By ngrmm
      i'm trying to attach a .ics-file to a mail
      The Page send sends out the email but only download the ics-file. Email has no attachments.
      // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $testEmail = $event->event_mail_test_adress; $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // .ics $filename = $event->name; header('Content-Encoding: UTF-8'); header('Content-type: text/calendar; charset=utf-8'); header("Content-Disposition: attachment; filename={$filename}.ics"); // fetch start date $event_start_ts = $event->getUnformatted("date_start"); // build the .ics data $ical_data = 'BEGIN:VCALENDAR'; $ical_data .= "\r\n"; $ical_data .= 'VERSION:2.0'; $ical_data .= "\r\n"; $ical_data .= 'CALSCALE:GREGORIAN'; $ical_data .= "\r\n"; $ical_data .= 'METHOD:PUBLISH'; $ical_data .= "\r\n"; $ical_data .= 'BEGIN:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'SUMMARY:'.$event->title; $ical_data .= "\r\n"; $ical_data .= 'UID:' . md5(uniqid(mt_rand(), true)) . '@'.$config->httpHost; $ical_data .= "\r\n"; $ical_data .= 'CLASS:PUBLIC'; $ical_data .= "\r\n"; $ical_data .= 'STATUS:CONFIRMED'; $ical_data .= "\r\n"; $ical_data .= 'DTSTART:'.date('Ymd', $event_start_ts).'T'.date("His", $event_start_ts); $ical_data .= "\r\n"; $ical_data .= 'DTSTAMP:'.date('Ymd').'T'.date('His'); $ical_data .= "\r\n"; $ical_data .= 'LOCATION:'.$event->venue; $ical_data .= "\r\n"; $ical_data .= 'URL:'.$event->httpUrl; $ical_data .= "\r\n"; $ical_data .= 'END:VEVENT'; $ical_data .= "\r\n"; $ical_data .= 'END:VCALENDAR'; // HTML BODY ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // send email $m = new WireMail(); $m->to($testEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->attachment($ical_data); $m->send();  
    • By ngrmm
      I have a page which sends out an email based on queries in the url
      <?php // event ID $eventID = $input->get('eventID','int'); $event = $pages->get($eventID); // config $adminEmail = "events@test.com"; $fromEmail = "noreply@test.com"; $fromName = "test"; $emailSubject = "Test Email"; // HTML BODY $emailBody = ""; // HOW TO ??? … // send mail $m = new WireMail(); $m->to($adminEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); ?> The email body is a bit complex: standard html/css tables and some php (pw variables).
      I put my emailbody (html) in a seperate file emailbody.inc but don't know how to include it?
       
    • 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.
×
×
  • Create New...