Hello

I have installed elastic_email, mailsystem and mimemail modules. At mailsystem admin page I configure NEW CLASS - I choose "format() method" by MimeMailSystem and "mail() method" by ElasticEmailMailSystem. By "Site-wide default MailSystemInterface class" I choose my new class - "MimeMailSystem_ElasticEmailMailSystem".
In RULES action I add Send e-mail (or Send HTML e-mail), fill all fields (with HTML message) and fire this rules.
After rules fired I get HTML email with additional text: "This is a multi-part message in MIME format. --5c7bb7ad08392cba9f7aae56de9051dfc350c32b1 Content-Type: multipart/alternative; boundary="c5c4527fb38b58306095527da6e6c93029064ba70" Content-Transfer-Encoding: 8bit --c5c4527fb38b58306095527da6e6c93029064ba70 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit......".
I tried all another combination in mailsystem admin page, but nothing happens.
How can I send the correct html email?

Thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webrelab created an issue. See original summary.

mike.davis’s picture

Hi, thanks for using this module.

I have had a similar issue recently with a college of mine when using MimeMail to send HTML emails.

Due to the way that the email is generated in Drupal there are some incorrect headers set which means that the data sent to Elastic Email is incorrectly formatted.

My college has fixed this, but I have been waiting for him to post a patch.

I will chase him on this as this patch should then help you out with this too :).

Thanks
Mike

mike.davis’s picture

Hi @webrelabs,

I have managed to get the patch from my college which I think will solve this issue. It is related to another issue that we were working on - #2657814: Separate plain text and html body value for sending emails with MimeMail, so I posted the updated patch to this thread.

Can you please test this patch and let me know how you get on and if this solves your issue?

I haven't fully tested it yet, only initially checked it over with my local dev copy, which seems to be working fine. One thing I have noticed is that it seems to always send using the provided theme rather than having a setting to determine if you want to send email as HTML or as plain text.

Please review and let me know if you have any further ideas about this etc. and/or provide an updated patch for this as this would be a great addition to this module.

Thanks
Mike

webrelab’s picture

Hi @mike.davis

I'm trying this patch.
Patching output:

patching file elastic_email.module
Hunk #1 FAILED at 171.
1 out of 1 hunk FAILED -- saving rejects to file elastic_email.module.rej
can't find file to patch at input line 68
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/lib/elastic_email.mail.inc b/lib/elastic_email.mail.inc
|index 579bef5..952144e 100644
|--- a/lib/elastic_email.mail.inc
|+++ b/lib/elastic_email.mail.inc
--------------------------
File to patch: lib/elastic_email.mail.inc
patching file lib/elastic_email.mail.inc                                    
Hunk #3 FAILED at 249.                                                       
1 out of 3 hunks FAILED -- saving rejects to file lib/elastic_email.mail.inc.rej 
patching file elastic-email-message.tpl.php                               
patching file elastic_email.theme.inc

When I trying fired rules to send HTML email, I have same result, with additional email header in message body (default class in mail system - MimeMailSystem_ElasticEmailMailSystem). When I choose default class by ElasticEmailMailSystem - I get an fatal error "PHP message: PHP Fatal error: Call to undefined function elastic_email_prepare_message() in /var/www/bn/sites/all/modules/elastic_email/lib/elastic_email.mail.inc on line 36"

mike.davis’s picture

OK I had created the patch against the dev copy which has got a couple of additional minor commits.

I'll have a look at creating a patch against the 7.x-2.0 tag

mike.davis’s picture

Status: Active » Needs review
FileSize
9.8 KB

Here is an updated patch against the 7.x-2.0 release, which should apply correctly against the 7.x-2.0 version.

webrelab’s picture

I get an fatal error

PHP Fatal error:  Cannot redeclare elastic_email_prepare_message() (previously declared in /var/www/bn/sites/all/modules/elastic_email/elastic_email.module:206) in /var/www/bn/sites/all/modules/elastic_email/elastic_email.module on line 264
Drush command terminated abnormally due to an unrecoverable error.
Error: Cannot redeclare elastic_email_prepare_message() (previously declared in /var/www/bn/sites/all/modules/elastic_email/elastic_email.module:206) in /var/www/bn/sites/all/modules/elastic_email/elastic_email.module, line 264
mike.davis’s picture

Argh sorry ... that'll learn me for trying to rush this :(.

OK, can you please try this one.

webrelab’s picture

I am very grateful to you for your help.

I get an warnings

   Warning: include_once(/var/www/bn/sites/all/modules/elastic_email/theme/elastic_email.theme.inc): failed to open stream: No such file or directory в функции _theme_process_registry() (строка 565 в файле /var/www/bn/includes/theme.inc).
    Warning: include_once(): Failed opening '/var/www/bn/sites/all/modules/elastic_email/theme/elastic_email.theme.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') в функции _theme_process_registry() (строка 565 в файле /var/www/bn/includes/theme.inc).

When I trying fired rules to send HTML email, I have same result, with additional email header in message body (default class in mail system - MimeMailSystem_ElasticEmailMailSystem).
When I choose default class by ElasticEmailMailSystem - email recieved with empty message.

mike.davis’s picture

No problems, happy to help with this :).

It seems to not be recognising the elastic_email.theme.inc file which should be there.

Is the the file '/var/www/bn/sites/all/modules/elastic_email/theme/elastic_email.theme.inc' on your server?
If so, have you cleared cache after applying the patch?

I haven't tried sending using rules, but sending normal emails from a site came through correctly using the HTML template.

If you send a email via the contact form for instance (which is using Drupals built in mail ti send rather than rules) does the email come through alright?

webrelab’s picture

Patch creates template files in module root folder. After moving it in theme folder, warning message is disappears. But, problem persist if I use contact form or if I use rules.

mike.davis’s picture

Mmm.... looking at the patch it creates the templates files within the theme folder. I have just tested the applying of the patch it works correctly adding the files to relevant directory.

I haven't tried sending an email using Rules, but I will have a look at this when I get a chance. However send a standard email from the contact form seems to come through fine using the supplied HTML template correctly.

Can you revert the patch from your module so that you have the base version of 7.x-2.0 and re-apply the patch again to see if this works at all?

webrelab’s picture

Maybe I not understand how correctly use patch?

I'm downloading patch file into elastic_email module path and give command "patch < 2713709-send-html-email-from-rules-8.patch"

root@bn-portal:/var/www/bn/sites/all/modules/elastic_email# patch < 2713709-send-html-email-from-rules-8.patch 
patching file elastic_email.module
can't find file to patch at input line 73
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/lib/elastic_email.mail.inc b/lib/elastic_email.mail.inc
|index f49918a..75d3781 100644
|--- a/lib/elastic_email.mail.inc
|+++ b/lib/elastic_email.mail.inc
--------------------------
File to patch: lib/elastic_email.mail.inc
patching file lib/elastic_email.mail.inc
patching file elastic-email-message.tpl.php
patching file elastic_email.theme.inc

Template files create in module root folder

mike.davis’s picture

OK - it looks like you aren't quite applying the patch correctly. Details of how to apply patches can be found here - https://www.drupal.org/patch/apply

You are nearly there, just missing a flag on the patch command. You need to use: patch -p1 < 2713709-send-html-email-from-rules-8.patch

This should then apply correctly without causing any problems. Let me know how you get on and if this then means that the email is sent correctly?

webrelab’s picture

With flag -p1 patch working correctly. Message was sent with html template, but message was sent as text/plain.
Give me a short instruction about configuring modules - mailsystem, elastic_email, and whether to use mimemail module.

mike.davis’s picture

I'm glad you have managed to get the patch applying correctly. I've not used the module with Mimemail, but my understanding is that you should not need Mimemail as the ElasticEmail module handles the sending of the HTML email for you with this patch.

Can you try it without the Mimemail module enabled?

webrelab’s picture

I try again without mimemail module. After reinstall patched elastic_email module, when I receive email from contact form, or from rules - "Content-Type: text/plain; charset=utf-8"

webrelab’s picture

@mike.davis, may have a way to change the type of pisma forced to html? What part of the code should be corrected, that would be the letters are always sent to html?

mike.davis’s picture

Hi @webrelab, the module determines if the email should be sent as HTML or text based upon the headers that are parsed to it when the email is sent.

It sounds like something is setting the headers of the email to be HTML before it gets to the Elastic Email mailer as this is what determines it.

From what you have said, you are trying to send emails using rules and this is always sending the email as plain text - is that right?
Have you been able to send an email from the standard site contact form, as this would be sent through the Elastic Email mailer and the current patch sets all email to be HTML?

Thanks
Mike

timlie’s picture

Is there any progress on this patch?
Patching version 2.2 of the module for drupal 7 does not work anymore.
I can confirm though that sending emails through rules are not send as html and thats very sad because elasticmail works really nice!

mike.davis’s picture

Hi @timlie, there hasn't been any further progress made unfortunately as I hadn't received any details back from @webrelab.

It would be great to get this working with Rules.

Can you please provide the exact set up that you have (modules that you are using etc.) and how you have configured a Rules to send an email and I will have a look into this further to see what needs to be done for this.

Thanks
Mike

timlie’s picture

Hi Mike, thanks!

I'm using the following modules:

rules-7.x-2.9
commerce_email-7.x-2.x-dev
variable-7.x-2.5

I created a rule with action:

Send mail with Variable

This actions sends a preconfigured commerce email variable.
These variables are in full html.

When receiving the e-mail from elasticemail its plain text. Sending with mimemail and builtin php mailer sends them as html emails.

timlie’s picture

Hi Mike,

If I need to provide you with more info, just let me know!

timlie’s picture

Hi Mike,

May I ask if there is any movement for this issue?

Thanks!

mike.davis’s picture

Hi @timlie,

Sorry I haven't had much time to be able to have a look at this recently. I'll try and see if I can squeeze in some time to have a look at this.

Thanks
Mike

timlie’s picture

Hi Mike,

I managed to send the emails in html with htmlmail (7.x-2.65 version).

Thanks!