Trying to improve product notification email
- burt
- Core Team
- Posts: 4560
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 413 times
Re: Trying to improve product notification email
Do bear in mind, that once you send out an email with images, you can never delete (or move) those images from your server...as the recipient might come back to the email in a month, year or 5 years and see a broken image placeholder rather than (eg) your logo/product image etc.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Trying to improve product notification email
We have had no issues with sending HTML emails with PHP 7.4.
We updated to PHP 8.0 and now emails are being received with additional code and are not displayed as expected e.g.
Code: Select all
--=_270f01f94224d71ab1595d294b82d3e5
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Trying to improve product notification email
I'm guessing that this relates to https://stackoverflow.com/q/70502065/6660678heatherbell wrote: ↑Fri Jul 15, 2022 4:52 am We updated to PHP 8.0 and now emails are being received with additional code and are not displayed as expected
I.e. change your line endings to CRLF for PHP 8, even when using sendmail/Linux.
-
heatherbell
- Senior Contributor
- Posts: 2540
- Joined: Mon Oct 07, 2019 4:39 am
- Phoenix Version:
- Has thanked: 35 times
- Been thanked: 243 times
Re: Trying to improve product notification email
Yes, your guess is spot on! Many thanks.ecartz wrote: ↑Fri Jul 15, 2022 6:19 am I'm guessing that this relates to https://stackoverflow.com/q/70502065/6660678
I.e. change your line endings to CRLF for PHP 8, even when using sendmail/Linux.
Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Trying to improve product notification email
One or two probably silly questions about the order update notification using info_pages
I did manage to convert update order and create account notifications to show correctly using info pages.
When getting to n_update_order.php im stuck.
I have created an info page in admin with slug store_checkout
In admin editing this info page i tried using {{ORDER_ID}} or '{{ORDER_ID}}' or [[ORDER_ID]] but this is not working at all.
Using %3$s or so for this array is obviously not the way
In n_update_order.php i have added many placeholders to name a couple:
then for array $placeholders i have:
Any suggestions on this? Thx.
I did manage to convert update order and create account notifications to show correctly using info pages.
When getting to n_update_order.php im stuck.
I have created an info page in admin with slug store_checkout
In admin editing this info page i tried using {{ORDER_ID}} or '{{ORDER_ID}}' or [[ORDER_ID]] but this is not working at all.
Using %3$s or so for this array is obviously not the way
In n_update_order.php i have added many placeholders to name a couple:
Code: Select all
$placeholders = [
['name' => 'CUSTOMER_NAME', 'content' => $order->customer['name']],
['name' => 'CUSTOMER_EMAIL', 'content' => $order->customer['email_address']],
['name' => 'ORDER_ID', 'content' => $order->get_id()],
Code: Select all
$email_body = sprintf($pages['pages_text'], $order->customer['name'], $order->customer['email_address'], $placeholders);- burt
- Core Team
- Posts: 4560
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 413 times
Re: Trying to improve product notification email
You've made placeholders too complicated, always keep it simple;
$placeholders = [
'CUSTOMER_NAME' => 'Mickey',
'CUSTOMER_EMAIL' => 'Mouse',
'ORDER_ID' => '123',
];
Now you can do $placeholders['CUSTOMER_NAME'] to return that customers name.
eg; in the language file;
const BLAH_BLAH = 'Hi %1$s, we updated your order %2$s. %1$s if you need to get in touch, please email us on ...';
Then using the language define in some other file (the processing file, the one that sends email);
sprintf(BLAH_BLAH, $placeholders['CUSTOMER_NAME'], $placeholders['ORDER_ID']);
Would result in;
sprintf(BLAH_BLAH, $placeholders['ORDER_ID'], $placeholders['CUSTOMERS_NAME']);
which would result in;
$placeholders = [
'CUSTOMER_NAME' => 'Mickey',
'CUSTOMER_EMAIL' => 'Mouse',
'ORDER_ID' => '123',
];
Now you can do $placeholders['CUSTOMER_NAME'] to return that customers name.
eg; in the language file;
const BLAH_BLAH = 'Hi %1$s, we updated your order %2$s. %1$s if you need to get in touch, please email us on ...';
Then using the language define in some other file (the processing file, the one that sends email);
sprintf(BLAH_BLAH, $placeholders['CUSTOMER_NAME'], $placeholders['ORDER_ID']);
Would result in;
The %1$s %2$s %3$s etc mean NOTHING until you pass data into the language define/const. You could just as easily pass;Hi Mickey, we updated your order 123. Mickey if you need to get in touch, please email us on ...
sprintf(BLAH_BLAH, $placeholders['ORDER_ID'], $placeholders['CUSTOMERS_NAME']);
which would result in;
Hi 123, we updated your order Mickey. 123 if you need to get in touch, please email us on ...
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 times
Re: Trying to improve product notification email
@Omar_one Fix for email content not appearing in PHP 8.heatherbell wrote: ↑Fri Jul 15, 2022 6:28 am Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
- Pierre_P
- Contributor
- Posts: 144
- Joined: Fri Mar 12, 2021 5:06 am
- Phoenix Version: v1.1.0.6
- Has thanked: 21 times
- Been thanked: 11 times
Re: Trying to improve product notification email
Burt, using the sprintf for checkout it's a lengthy one.
Using info_pages i did manage to get create account and update order successfully, the checkout page is bit more frustrating for me getting al the html table tags to show correct format.
Altering the info page later i will have no idea what all the placeholders were for reference.
What i rather want to know is can we use for example like a short tag for CUSTOMER_NAME, then in info_pages to be {{CUSTOMERS_NAME}} instead of placeholders from sprintf ? - similar to canned comments (Magical Unicorns)
-
Omar_one
- Senior Contributor
- Posts: 679
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: Trying to improve product notification email
thank you @ecartzecartz wrote: ↑Sat Nov 11, 2023 10:17 pm@Omar_one Fix for email content not appearing in PHP 8.heatherbell wrote: ↑Fri Jul 15, 2022 6:28 am Configuration > E-Mail Options > E-Mail Linefeeds, changed to CRLF and now HTML emails displayed as expected.
I have changed that ..this fix the Order Update email which send by admin, but not order confirmation email which the customers got after buying ,, still order info not shown there, but the product reviews links appearing the email ,
am not sure if the issue from core or from Purchase Without Account module as this module which effect on the "listen_orderMail" method on shop side