HTML emails

Permalink 4 users found helpful
I am using the Extended Form block, but I think it uses the same code as the regular c5 form to send out alert emails. I need to make the alert email that gets sent out an HTML email (logo, basic colors, etc) has anyone ever done this or have any pointers on how to go about it? Thanks -Brian

hursey013
View Replies:
mbone99 replied on at Permalink Reply 1 Attachment
Haven't looked at integrating with Extended Form block, but we've started using the attached to send html email, ie:
$mh2 = Loader::helper('mail2');
$mh2->to($to); 
$mh2->from($from); 
$mh2->setSubject($subject);
//send both and let email client decide
$mh2->setBody($textBody);
$mh2->setHtml($htmlBody);
@$mh2->sendMail();
Mnkras replied on at Permalink Reply
Mnkras
really nice job mbone99,

i just made custom mail templates, ;)

in tony's mail addon, he uses a stripped down tinymce so its easy to style,
pvernaglia replied on at Permalink Reply
pvernaglia
Excellent solution, thanks!
arteconceito replied on at Permalink Reply
arteconceito
Hi guys!
mbone99, thank you very much for posting this great and easy to use solution.
Cheers ;-)
jordanlev replied on at Permalink Reply
jordanlev
For future reference, just want to point out that is seems the built-in C5 mail helper includes HTML support (in 5.4.1.1 for sure, don't know about earlier versions).

To use it, just call the setBodyHTML() function. For example:
$mh = Loader::helper('mail');
$mh->to($to);
$mh->from($from);
$mh->setSubject($subject);
$mh->setBody($textBody);
$mh->setBodyHTML($htmlBody);
@$mh->sendMail();
jordanlev replied on at Permalink Reply
jordanlev
Someone recently asked how to make the built-in form block send HTML emails in 5.5. Here's how:

1) Copy this file:
SITEROOT/concrete/mail/block_form_submission.php

...to here:
SITEROOT/mail/block_form_submission.php


2) Edit the new copy of the file, and change this line:
$body = t("

...to this:
$bodyHTML = t("


3) Now you can edit the contents of the email to be HTML. Note that you might also want to define a plain old $body variable (if you want the email to have both HTML and plain text versions). Also, for the HTML email you'll probably want to change the line breaks in between each question/answer pair into <br /> tags (so on line 6, replace each "\r\n" with "<br />").

-Jordan
terrordaddy replied on at Permalink Reply
Hi Jordan,

I tried this with concrete 5.5.2.1 but it doesn't work for me.
The email will be send but it has no content.
What im doing wrong?

Kind regards
- Kevin
jordanlev replied on at Permalink Reply
jordanlev
Please post the mail template file (the one you put into SITEROOT/mail/block_form_submission.php).
terrordaddy replied on at Permalink Reply
Hi Jordan,

Thanks for you reply.
I got it to work. There will be send an email.
But when i set a table to the block_form_submission.php like:

<TABLE>
  <TR>
    <TD>
      TEST
    </TD>
  </TR>
</TABLE>


The form will hangs up.
After i click Submit, the screen turns white.
How can i format my HTML-Email?
Can i use normal HTML-Tags?

Kind regards
-Kevin
jordanlev replied on at Permalink Reply
jordanlev
Please post the mail template file (the one you put into SITEROOT/mail/block_form_submission.php).
Mainio replied on at Permalink Reply
Mainio
I've thought for long that defining the HTML email is really clunky in C5. It should be easy to write out the mail template as you write any view template.

I've also done a pull request of this with no comments for ½ a year:
https://github.com/concrete5/concrete5/pull/406...
ebrongers replied on at Permalink Reply
ebrongers
Thanx Jordanlev,

this is exactly where I was looking for.

Best regards,
Eric Brongers
Proracom