GiovanniSalmeri / yellow-mailer

Email creation and transfer.
GNU General Public License v2.0
5 stars 0 forks source link

HTML hardcoded in mailer.php #2

Open Arkileogisticologist opened 2 years ago

Arkileogisticologist commented 2 years ago

Hi! This is a really good alternative to the standard contact extension, but the template being hardcoded into mailer.php has me worried about making changes. Are there any plans to move the template to a separate file?

GiovanniSalmeri commented 2 years ago

Hello! First of all: I meant the contact form only as a very simple example of use of the API of email creation and transfer which this extension offers.

As regards HTML email, the hardcoded template (in lines 413-428) is actually nothing more than an essential boilerplate, which is identical in any HTML email. But the API gives the possibility of 1. specifying a CSS 2. specifying the heading 3. specifying the body 4. specifying the signature. If any of 2, 3, 4 is not specified, then the respective content is automatically obtained from the text/plain version, interpreted as markdown.

Presently none of these possibilities is used by the contact form. Normally, contact forms are meant to contact a society, and an elaborate formatting is in general of little use in this case. But nothing prevents from using some of the possibilities mentioned above. For example, in order to add a fancier signature one could add after line 50 (not tested):

$mail['text']['html']['signature'] = "<div style=\"background:yellow;padding:5px;font-size:1.2em\">".htmlspecialchars($page->getRequest('name'))."</div>\n";

Yes, this requires modifying the extension... but it would be easy to make a simple system of external templates. I could think about it. Could you say more exactly what is your use case?

Arkileogisticologist commented 2 years ago

I'm using the extension as a simple contact form on a one-page website (the AJAX functionality is really useful in that respect). I've already modified the extension somewhat by adding the placeholder attribute on the form textarea and input tags (lines 63-73), and removed the labels above each field for a different look.

I'm not too concerned about doing anything too elaborate, and of course styling can always be done via a separate CSS file. My concern is more that if the extension is updated, I'll lose my modifications and will have to re-do them (AFAIK Yellow doesn't let you exclude an extension when updating).

GiovanniSalmeri commented 2 years ago

I understand. Finding the right balance between simplicity of use and configurability is always a matter of compromise. Generally I try to follow the spirit of Yellow, where the former is preferred, but I will think better to this question. If I devise a super-simple template system (for the form and for the email) which does not add too much complexity, I will update the extension. Thank you for asking!