View Issue Details

IDProjectCategoryView StatusLast Update
0025670mantisbtemailpublic2019-04-21 02:54
Reporterkeessonnema Assigned Todregad  
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionno change required 
Product Version2.20.0 
Summary0025670: Is there a way to enable HTML emails (PHPMailer) without changing the value $mail->isHTML( false ); in the core?
Description

I'm working on a plugin that sends e-mails, but need to send HTML formatted e-mails. The only option I found is to enable the isHTML flag in email_api.php

TagsNo tags attached.

Relationships

duplicate of 0012830 new new HTMLMail plugin v0.1 

Activities

keessonnema

keessonnema

2019-04-04 06:41

reporter   ~0061824

@atrol I don't think this was clear. I'm working on my own plugin that sends an email. I don't want HTMLMail plugins to send HTML formatted emails.

dregad

dregad

2019-04-04 07:13

developer   ~0061825

Is there a way to enable HTML emails (PHPMailer) without changing the value $mail->isHTML( false ); in the core

No.

stevecharon

stevecharon

2019-04-11 04:53

reporter   ~0061884

Last edited: 2019-04-11 04:55

Oh, I just have done something like that because of this "No".
I think still relying on text-emails in a responsive web application is somewhat unbalanced.
So here is, what I did:
// in file=/core/email_api.php ;
$t_mail->Encoding = 'base64';
$t_mail->Subject = $t_subject;
// $t_mail->Body = make_lf_crlf( $t_message );
$t_mail->AltBody = make_lf_crlf( $t_message );
$t_mail->IsHTML( true );
$t_mail->Body = nl2br($t_mail->AltBody);

The default ishtml(false); is still in place somewhere above, but is overwritten in the code shown here.
By setting AltBody you have backward compatibility with non-html viewers.
Then the plain text new lines are converted to html line breaks using standard php function nl2br to get propper wrapping.
That way I can use html emails without destroying default notifications line breaks.
Dont know if that is what you need.
But just give it a go.
Oh, I had the best results by setting encoding back to base64, default value for phpmailer itself, so I put up there too.
quoted-printable and 8bit have not worked well in my environment.

dregad

dregad

2019-04-11 09:20

developer   ~0061885

I had the best results by setting encoding back to base64, default value for phpmailer itself, so I put up there too.
quoted-printable and 8bit have not worked well in my environment.

Quoted-printable was set as a fix for 0016871.

@stevecharon For the record, the PHPMailer default is 8-bit, not base64, and it has been so since as far back as the library's Git history goes (v2.2.1, 2008 [1])