New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Documents] Newsletter: add option to maintain a manual edited plain-text version #4794
Changes from all commits
02400ef
024faa3
90d16af
eef5b8e
2a33c73
74e90c2
c78e393
b12d062
c186695
1f8a8d0
42c0717
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Enterprise License (PEL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PEL | ||
*/ | ||
|
||
pimcore.registerNS("pimcore.document.newsletters.plaintextPanel"); | ||
pimcore.document.newsletters.plaintextPanel = Class.create({ | ||
|
||
initialize: function(document) { | ||
this.document = document; | ||
}, | ||
|
||
getLayout: function () { | ||
|
||
if (this.layout == null) { | ||
|
||
this.layout = new Ext.FormPanel({ | ||
title: t('plain_text'), | ||
border: false, | ||
autoScroll: true, | ||
bodyStyle:'padding:0 10px 0 10px;', | ||
iconCls: "pimcore_material_icon_text pimcore_material_icon", | ||
items: [ | ||
{ | ||
xtype:'fieldset', | ||
title: t('plain_text_email_part'), | ||
itemId: "plaintextPanel", | ||
collapsible: true, | ||
autoHeight:true, | ||
defaults: { | ||
labelWidth: 200 | ||
}, | ||
defaultType: 'textarea', | ||
items :[ | ||
{ | ||
fieldLabel: t('plain_text') + " (" + this.document.data.plaintext.length + ")", | ||
maxLength: 4000, | ||
height: 700, | ||
width: 1400, | ||
name: 'plaintext', | ||
itemId: 'plaintext', | ||
value: this.document.data.plaintext, | ||
enableKeyEvents: true, | ||
listeners: { | ||
"keyup": function (el) { | ||
el.labelEl.update(t("plain_text") + " (" + el.getValue().length + "):"); | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}); | ||
} | ||
|
||
return this.layout; | ||
}, | ||
|
||
getValues: function () { | ||
|
||
if (!this.layout.rendered) { | ||
throw "plaintext not available"; | ||
} | ||
|
||
// get values | ||
var plaintext = this.getLayout().getForm().getFieldValues(); | ||
return plaintext; | ||
} | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,10 @@ public static function prepareMail( | |
if ($sendingContainer && $sendingContainer->getParams()) { | ||
$mail->setParams($sendingContainer->getParams()); | ||
} | ||
|
||
if(strlen(trim($newsletterDocument->getPlaintext())) > 0) { | ||
$mail->setBodyText(trim($newsletterDocument->getPlaintext())); | ||
} | ||
|
||
$contentHTML = $mail->getBodyHtmlRendered(); | ||
$contentText = $mail->getBodyTextRendered(); | ||
|
@@ -115,6 +119,8 @@ public static function prepareMail( | |
|
||
$mail->setBodyHtml($contentHTML); | ||
$mail->setBodyText($contentText); | ||
// Adds the plain text part to the message, that it becomes a multipart email | ||
$mail->addPart($contentText, 'text/plain'); | ||
$mail->setSubject($mail->getSubjectRendered()); | ||
|
||
return $mail; | ||
|
@@ -137,8 +143,6 @@ public static function sendNewsletterDocumentBasedMail(Mail $mail, SendingParamC | |
|
||
if (!empty($mailAddress)) { | ||
$mail->setTo($mailAddress); | ||
// Getting bounces | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why removing this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not necessary, as the SMTP Server will set it automatically set the return path when finally sending the email. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You added this in #4349 ... can't hurt to leave it as it is, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know it was me. :-) |
||
$mail->setReturnPath(key($mail->getFrom())); | ||
|
||
$mailer = null; | ||
// check if newsletter specific mailer is needed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? See:
pimcore/lib/Mail.php
Line 567 in d688a67
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 567 is part of the send function, the newsletter is send via sendWithoutRendering function:
Pimcore::getEventDispatcher()->dispatch(DocumentEvents::NEWSLETTER_PRE_SEND, $event);
$mail->sendWithoutRendering($mailer);
Pimcore::getEventDispatcher()->dispatch(DocumentEvents::NEWSLETTER_POST_SEND, $event);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point 👍😊