There is a confirmed issue in some Magento 2 versions: an order is placed successfully, but the customer receives two order confirmations for the same order. The cause is not necessarily the mail server, SMTP module or custom sending logic.…
Fixing Incorrect authentication data (Magento 2)
You or your customers may encounter the message Incorrect authentication data in various places in Magento 2, both on the storefront and in the admin area. You are probably sending mail through SMTP, and the saved authentication details are incorrect…
Contact form message content appears as a single line (Magento 2)
Are comments submitted through the Magento 2 contact form displayed as a single line, losing the sender’s line breaks? A small change to your email template can solve that. Change the following line in your email template:
|
1 |
{{var data.comment}} |
to
|
1 |
{{var data.comment|nl2br}} |
…
Adding BCC to a transactional email (Magento 1)
Use the following code to add a BCC recipient to a Magento transactional email:
|
1 2 3 |
Mage::getModel('core/email_template') ->addBcc('test@example.com') ->sendTransactional(...); |
Changing customer email addresses in Magento
When testing new features locally on your development machine, it is advisable to change the customers’ email addresses. You can use the following script for this purpose: Warning: Never execute these statements on a production system!
|
1 2 3 4 |
update sales_flat_quote set customer_email = (concat(substring(md5(rand()) from 1 for 20), '@example.com')); update sales_flat_order set customer_email = (concat(substring(md5(rand()) from 1 for 20), '@example.com')); update sales_flat_quote_address set email = (concat(substring(md5(rand()) from 1 for 20), '@example.com')); update customer_entity set email = (concat(substring(md5(rand()) from 1 for 20), '@example.com')); |
Now open an…
Changing Magento store email addresses in a local installation
Warning: Never execute these statements on a production system! The following query generates an update script according to a pattern you define. In this example the pattern is “your-domain.com”. Replace it with your own domain.
|
1 2 |
select concat('update core_config_data set value = \'test@example.com\' where path = \'', path, '\';') from core_config_data where value like '%@ihre-domain.de%' |
The resulting script might…
Writing HTML mail templates that are not considered as spam (Magento 1)
Follow these rules and your mail templates will most likely not be considered as spam: 1. Always wrap the content in … 2. Remove all empty lines 3. Remove all font size definitions, like font:11px/1.35em 4. Avoid spam words such…
Loading a mail template by its name (Magento 1)
Use the below code to load a Magento transaction mail template by its name:
|
1 2 |
$templateId = Mage::getModel('core/email_template')->loadByCode('<name>')->getTemplateId(); $template = Mage::getModel('core/email_template')->load($templateId); |
Getting mail template content by name (Magento 1)
Use the following code to get a mail templates content by its name:
|
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $templateByName = $mailTemplate->loadbyCode($templateName); $text = $templateByName ->getData('template_text'); |
Getting mail template content by id (Magento 1)
Use the following code to get a mail templates content by its id:
|
1 2 3 |
$mailTemplate = Mage::getModel('core/email_template'); $template = $mailTemplate->load($templateId); $text = $template->getData('template_text'); |