CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Mailing presets extension (and third-party integration)
Pages: [1]

Author Topic: Mailing presets extension (and third-party integration)  (Read 1007 times)

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Mailing presets extension (and third-party integration)
November 23, 2015, 07:34:58 am
We often ran into the issue of clients who wrote their newsletter content on their website, or used Drupal Views to generate their newsletter, then wanted to copy-paste that HTML into CiviMail.

Another source of occasional source of confusion for users is to identify what are their main communication channels and what groups are associated to them. The simplest way around this is to "re-use" a previously sent mailing. Still, this doesn't really give a good overall view of the mailings.

So I created an extension that takes care of these two issues:

1- makes it easy to define CiviMail "presets": name, subject, recipient groups, message template (and will add other settings too, such as click-through/response settings, etc).
2- makes it possible to copy an HTML snippet into your website so that you have a handy "create mailing" button which takes the HTML of that webpage, merges it with a message template, and creates a new mailing using your preset.

That probably sounds a bit abstract, so I did a quick video demo:
https://www.youtube.com/watch?v=TPEBsHOPelI

It is still at an early stage of development. If you want to try this at home, you have to understand how "CORS" (cross-origin-ressource-sharing) works.

In my setup, both sites were using https, and my CiviCRM site had this in the Apache configuration:

Code: [Select]
Header add Access-Control-Allow-Origin "https://www.bidon.ca"
Header add Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header add Access-Control-Allow-Headers "Content-Type, Connection, Depth, User-Agent, X-File-Size, X-Requested-With, Set-Cookies"
Header add Access-Control-Allow-Credentials "true"

# the pre-flight CORS check needs only headers. Avoid sending to CiviCRM, where it would 403.
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^/civicrm/ajax/rest$ /CHANGELOG.txt [QSA,L]

Another thing not shown in my demo, is that the HTML snippet says which HTML/DOM area to use in the mailing. In my case, I use ".main-container", which is the "div" around my node. That's why the "edit/view" menu was included in the mailing content. You can edit the HTML snippet to specify another div.

As usual, comments/suggestions/patches/sponsors welcome.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Mailing presets extension (and third-party integration)
November 23, 2015, 11:39:16 am
This looks great Mathieu, nice work!

I think the work you are doing around CORS is really critical. Although it's out of scope for this project.... if we can apply this to allow profiles, event registration and donation pages to be placed on remote servers it would be great.

Do you have the code published somewhere?

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: Mailing presets extension (and third-party integration)
November 23, 2015, 11:56:50 am
Hi Jamie,

Thanks for the feedback!

Code is on Github:
https://github.com/coopsymbiotic/coop.symbiotic.mailingpresets

I think that profiles and contribution pages could be integrated with an iframe (à-la-Youtube embed). There are still some challenges around that (notably theming and error handling). Zyxware have published an interesting extension called "civiwci" (civi widgets) that does part of that: https://civicrm.org/extensions/civiwci

One reason why I had to use CORS for this extension, is that the javascript loaded from the CiviCRM extension needs to access the DOM of the third-party site (to copy the page content and send it to civicrm). I also needed to do things such as a cross-origin request that included the authentication cookie. There's also a caveat with CORS: the browser must allow third-party cookies in Chrome/Safari, so I'm not sure to which extent we can expect the visitor to have proper support. It doesn't bother me in this case, because it's an administrative feature.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Mailing presets extension (and third-party integration)
November 23, 2015, 12:21:31 pm
Neat idea! I especially like the presentation on Youtube.


jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Mailing presets extension (and third-party integration)
November 24, 2015, 07:28:21 am
We have been pushing iframes pretty heavily over the years however recently have had a lot of angry people who found out that their contribution pages were throwing errors with certain browsers.

We finally realized we had to start using a P3P policy to allow Internet explorer to pass cookies. See:

https://stackoverflow.com/questions/389456/cookie-blocked-not-saved-in-iframe-in-internet-explorer

Maybe CORS will similarly have problems depending on the various security policies in place in a browser.

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: Mailing presets extension (and third-party integration)
November 25, 2015, 05:47:17 am
Very interesting, didn't know about P3P! Thanks for sharing.
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

e_mason

  • I post occasionally
  • **
  • Posts: 65
  • Karma: 1
  • Eliot Mason
  • CiviCRM version: 4.05
  • CMS version: Drupal 7
  • MySQL version: 5.1xx
  • PHP version: 3.53
Re: Mailing presets extension (and third-party integration)
December 13, 2015, 11:30:56 am
This is very clever and would really improve the integration of CiviMail.  The preset idea is great ... and would make it much easier to present pre-configured solutions to clients.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • Mailing presets extension (and third-party integration)

This forum was archived on 2017-11-26.