Hi,

I put the "HTML" option in the newsletter module and the smtp module but my confirmation message appears with all the HTML tags in my mailbox.

What's wrong??

CommentFileSizeAuthor
#34 issue.jpg104.89 KBDrupppie
#30 1388378-SMTP_html_emails-30.patch1023 bytesParisLiakos
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sophie30’s picture

Title: THML tag in email » HTML tag in email
ParisLiakos’s picture

Assigned: sophie30 » Unassigned

does it work,if you disable smtp?

sophie30’s picture

If i diable smtp module and i disable the checkbox "Enable SMTP support" in newsletter module, the mail is not send...

ParisLiakos’s picture

does any mail is being sent from the site at all?

sophie30’s picture

I don't know if I understand your request...If I disable smtp module, in the newsletter module there is a message of success when I send a test, but the email is not send...But when I put the smtp module on "On", it's ok, the mails are send but with all html tags

ParisLiakos’s picture

Unfortuantely, smtp doesn't handle the mail variable with the best possible way.
see this issue here : #1201198: Don't reset mail system variable

You ll have to uninstall newsletter and then reinstall it to fix the variable,or use the devel module.but keep smtp enabled.

after it is reistalled does test mail deliver?

sophie30’s picture

Ok, I'm going to try the dev version of your module. So, if I understand, I have to uninstall my newsletter module, but must I do uninstall the smtp module too??

ParisLiakos’s picture

no,keep smtp enabled:)

sophie30’s picture

I have just installed the dev version, and there is the HTML format activate but there is the same problem, my email are like this :

<p>This is a test e-mail generated by the Drupal Newsletter module.<br />
      If you succesfully received this e-mail,<br />
      it means that your server is capable of sending e-mails.<br />
      Congratulations!<br />
      You can now create lists, templates and subscribe users to them!</p>
ParisLiakos’s picture

thats very weird....
can you tell me the contents of mail_system variable?
use the devel module http://drupal.org/project/devel and its variable editor

Road Runner’s picture

I can confirm everything Sophie said. I am using latest Dec 20 .dev module. When smtp installed (yes I did it first and enabled it prior to installing Newsletter) smtp has a test email which does work with the email server I selected. So far so good. After that it is pretty much as Sophie said. Your module has promise but right now nothing. Also no way to resend email - I mentioned this before without this it isn't a production system. This is critical. FYiI, I am playing with Simple News, phpList and yours.
FYI when I look at headers of html email they say

X-Mailer: PHPMailer 5.1 (phpmailer.sourceforge.net)
Mime-Version: 1.0
Content-Transfer-Encoding: 8Bit
Content-Type: text/plain; charset="utf-8"

Maybe that will help as I believe when I look at headers of html email that comes through correctly it says something like the following
Content-Type: multipart/mixed; boundary="5794e8c2c8f...................."
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Priority: normal

sophie30’s picture

I installed it (the devel module) but where is the variable editor ??

ParisLiakos’s picture

@sophie30 under devel/variable

@Road Runner sorry,but smtp is a whole different module and unfortunately not well maintained.also i dont have any smtp capable server to test against.so its a bit difficult to know whats going on.That said if you see critical things missing you are welcomed to sponsor their development or start sharing some patches:)

Road Runner’s picture

Hi thanks for prompt response. FYI, Even without smtp module installed html doesn't work.

sophie30’s picture

I'm sorry but I don't understand this, I can't find this...:-(

ParisLiakos’s picture

@Road runner if it doesnt work then it is a bug.can you tell me the mail_system variable contents?

@sophie30 after you install devel there is a block available called Development.enable it.the last link in the block is Variable editor.There you can find the variable

Road Runner’s picture

sure, where do I find mail_system variable

ParisLiakos’s picture

install devel module and then navigate to devel/variable path

Road Runner’s picture

with smtp module uninstalled and newsletter module installed this is what I see.

a:1:{s:14:"default-system";s:17:"DefaultMailSystem";}

With smtp module installed but newsletter module uninstalled

a:1:{s:14:"default-system";s:14:"SmtpMailSystem";}

ParisLiakos’s picture

thats what i thought..smtp resets the variable -.-
sigh i think i should remove smtp support for now.
well to fix this do the following:

1) Disable newsletter.
2) Uninstall newsletter
3) Enable smtp
4) Enable newsletter.
5) check the variable.There should be a NewsletterMailSystem in there.
6) newsletter module can now send html email.

Alternatively,If you dont want to lose your newsletter data,run this php code into the execute PHP block devel provides:

  $mail_modes = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
  $mail_modes['newsletter'] = 'NewsletterMailSystem';
  variable_set('mail_system', $mail_modes);
Road Runner’s picture

Now with smtp installed and now newsletter installed this is what i get
a:2:{s:14:"default-system";s:14:"SmtpMailSystem";s:10:"newsletter...

when I click edit I see the following
Array
(
[default-system] => SmtpMailSystem
[newsletter] => NewsletterMailSystem
)

BTW, it is moot point because I still can't test a newsletter multiple times before sending to the list. For large mailings need smtp to redirect to a server with no throttle and for email marketers they need to be able to test and retest until final product is ready. Without these it isn't a production ready module.

ParisLiakos’s picture

I want to help:) so help me understand the problem.

1) Now,can you send html mails without smtp? (smtp checkbox unchecked)
2) if yes, when you check smtp, mail still sends but html fials?

Road Runner’s picture

OK. I have some other stuff that I have to do but here is first cut.

Only Newsletter is installed ( I uninstalled smtp)
Using Send Test on the newsletter setting tab I looked at header in the email I received and this is what I got. There is no html in your ttest email you might want to include that in future.
X-Mailer Drupal
Text/plain
8-bit encoding

Then using your default template to which I added some basic html and a couple of email addresses for test purposes I sent using the choice to send under the Create/Send tab.
I added some html t this template the one shown as default. then sent and ran cron manually.

No Email Received in this scenario.

ParisLiakos’s picture

smtp ruined the variables again.

when you disable it,it resets the variable again.check it in the devel variable editor to be sure

ParisLiakos’s picture

closing this as duplicate of #1201198: Don't reset mail system variable since smtp is clearly the problem here and the stupid variable resetting.sorry cant do much,i just hope that my patch gets commited soon,over to smtp,so you people using SMTP can start using Newsletter module

ParisLiakos’s picture

Status: Active » Closed (duplicate)
rurri’s picture

Category: support » bug
Status: Closed (duplicate) » Active

I can confirm the same issue. The e-mails are being received in the editor as plain text, which causes all of the HTML tags to show.

This only happens when sending mail via the SMTP module.

This is fixed with the following line added to newsletter.mail.inc in the function mail in the if block for the smtp module

  public function mail(array $message) {
    // SMTP check
    if (variable_get('newsletter_use_smtp', FALSE) && module_exists('smtp')) {
      $smtp = new SmtpMailSystem();
      if ($message['format']==='html') {
        $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
      }
      $message['body'] = array($message['body']);
      $message = $smtp->format($message);
      $mail_result = $smtp->mail($message);
    }

It looks like the content type needs to be set in the header in order for this to work.

rurri’s picture

Just to clarify, the block that needs to be added to the if block is:

     if ($message['format']==='html') {
        $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
      }

Sorry for lack of patch, I downloaded the module as a tar ball, so would require a bit of setup just to make this patch..

ParisLiakos’s picture

Version: 7.x-1.0-beta6 » 7.x-1.x-dev
Status: Active » Needs review

hmm interesting..thanks a lot for taking the time rurri

ParisLiakos’s picture

Title: HTML tag in email » HTML tag in email when using SMTP
FileSize
1023 bytes

patch attached

rurri’s picture

Took a look at the patch. Looks good, and better than repeating the code, pulling it up on top of the if block is much better since it needs to be set regardless of the way the e-mail is eventually being sent.

ParisLiakos’s picture

Status: Needs review » Fixed

thanks a lot rurri, i commited the patch
cheers

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Drupppie’s picture

Title: HTML tag in email when using SMTP » HTML tag in email when using SMTP -
FileSize
104.89 KB

Hi all,
I am using the latest newsletter module + smtp module.
Unfortunately i had to instal the smtp module second.

My newsletters appear with html tags, not in the html format.

I have all narrowed it down to the text in the header: Content-Type: text/plain; charset="utf-8" and not Content-Type: text/html; charset="utf-8".

Now, applying the fix for the "mail_system" variable works. The newsletters appear in html format, but I get and error:
PDOException: in field_sql_storage_field_storage_write() (line 448 of /var/www/html/test/modules/field/modules/field_sql_storage/field_sql_storage.module).
and also the newsletter in report appear as sending (not sent) - so every time i run cron they get resent.

Any suggestions?