Skip to main content
63 votes
Accepted

How does asynchronous email sending works in Magento 2

I had no idea how emails are sent in Magento 2, but your question took my interest so I investigated a little. I have started my investigation by searching email keyword on cronjobs, and got the ...
Bunyamin Inan's user avatar
33 votes
Accepted

How to send an email programmatically in Magento 2?

/** * Recipient email config path */ const XML_PATH_EMAIL_RECIPIENT = 'contact/email/recipient_email'; /** * @var \Magento\Framework\Mail\Template\TransportBuilder */ protected $_transportBuilder; /**...
Anil Singh's user avatar
32 votes

New order email confirmation not being sent

There are 2 methods to send mails from our Magento 1 store. By Using cron By Avoiding cron If you want to avoid cron : Open your order.php file at app/code/core/Mage/Sales/Model/Order.php Line#...
Teja Bhagavan Kollepara's user avatar
28 votes
Accepted

Magento 2 : How to add custom data in order email

(Update 2.3) use transportObject Use transportObject instead of transport $this->eventManager->dispatch( 'email_order_set_template_vars_before', ['sender' => $this, 'transport' => $...
Amit Bera's user avatar
  • 77.5k
27 votes
Accepted

How to solve the message "Character content other than whitespace"?

This problem you got because the XML code, you copy directly on internet/webpage, there is some hidden character before start each line. This isn't space/ newline character. So, when push to Magento, ...
Vu Anh's user avatar
  • 1,036
25 votes
Accepted

Magento 2: send email with Attachment

M2 does not come with out of the box however it is a feature built into the zend framework. Here is a good reference how to add this functionality into magento: https://blog.bitexpert.de/blog/sending-...
Xenocide8998's user avatar
  • 1,772
23 votes

How to render data type html in template email magento2?

I change {{trans "%body" body=$data.body}} to {{trans "%body" body=$data.body|raw}}. it render success.
xanka's user avatar
  • 2,114
21 votes
Accepted

Magento 2 - Emails -> if statement

We cannot use the if condition like: {{if order.customer_group_id == 1}} <p>Bla Bla Bla</p> {{/if}} We can find the customer group id in sales_order table. I also notice that the ...
Khoa TruongDinh's user avatar
20 votes

Magento 2: Sending Email Programmatically

Magento 2 TransportBuilder uses a email templates to compose email's body. The simplest way I found to send plain text - use Zend_Mail (that is used by Magento 2 itself): $email = new \Zend_Mail(); $...
Alex Gusev's user avatar
  • 2,009
19 votes

How to get magento store email address and name in my custom module?

To retrive store sender name and email address : General Contact /* Sender Name */ Mage::getStoreConfig('trans_email/ident_general/name'); /* Sender Email */ Mage::getStoreConfig('...
Aman Alam's user avatar
  • 1,318
18 votes
Accepted

Pass Variable And Output In Custom Email Template

Try this: $templateOptions = [ 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $this->storeManager->getStore()->getId() ]; ...
Sagar Dobariya's user avatar
18 votes
Accepted

How to create a custom form for sending email with file attachment in magento 2

Try below code in your controller vendorname/modulename/controller/Index/index.php <?php /** * * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ ...
Ravindrasinh Zala's user avatar
17 votes

Magento 2: send email with Attachment

As of Magento 2.2.7 the solutions described above do not work anymore since \Magento\Framework\Mail\Message dropped extending \Zend_Mail. To circumvent the lack of an easy way to add attachments ...
Jean-Bernard Valentaten's user avatar
17 votes

order confirmation email not send in magento 2

If you have properly configured Magento 2 mailing systems, you may need to check below point: Got to Stores -> Configuration -> Advanced -> System Under Mail Sending Settings make sure ...
Kamal Singh's user avatar
17 votes
Accepted

How to get email address by order id in Magento 2?

Try this : $order = $this->_objectManager->create('\Magento\Sales\Model\Order')->load($id); $email = $order->getCustomerEmail(); To get Customer Id : $customerId = $order->...
Ashish Jagnani's user avatar
13 votes

Magento 2: send email with Attachment

Magento 2.3.x Compatible: This was my answer for Magento 2.3 since this was a top question on google and there seems to be a lot of people in the comments looking. There seems to be a lot of desire in ...
domdambrogia's user avatar
13 votes

How to get store admin email address and name in Magento 2 in a Block?

You have to create first block and defined function inside block for getting store name and store email, inside construct method pass ScopeConfigInterface object Create the method getStoreName(), ...
Rakesh Jesadiya's user avatar
13 votes
Accepted

Magento 2 custom email template not including header

I had a slightly different problem but i think it would be good to post the solution here anyway as I came across this post when researching my issue. I have a custom module that triggers an email on ...
Frank's user avatar
  • 1,144
13 votes
Accepted

How to send emails to multiple users in magento2?

You may try this below code. if you want send to multiple email address you can use array format like $emails = ['[email protected]', '[email protected]']; $transport = $this->_transportBuilder->...
Jjo's user avatar
  • 1,158
12 votes

how to send custom email no template in magento2?

You need to create etc/email_templates.xml add below code <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...
Prashant Valanda's user avatar
12 votes

Magento 2 : Is there any way to disable Welcome Email after signup

Create a plugin for \Magento\Customer\Model\EmailNotification. Update di.xml <type name="\Magento\Customer\Model\EmailNotification"> <plugin name="disable-email-notification" type="...
Alex's user avatar
  • 121
11 votes

Magento 2 error: We're sorry, an error has occurred while generating this email

Enable developer mode using command line php bin/magento deploy:mode:set developer Clear cache using command line php bin/magento cache:flush Reload the front end page After reloading the page the ...
Kareem Sultan's user avatar
11 votes
Accepted

In Magento 1.9, why are order emails send through the queue, while Invoice emails are sent directly?

Orders email are sent using the queue for different reasons: Avoid frontend slowdown while sending out the email Resend on failure Avoid errors on checkout/post-checkout Solution 1 (send order's ...
Phoenix128_RiccardoT's user avatar
11 votes
Accepted

Magento 2 How can I validate the email confirmation field with the actual email field?

On the second reenter email address input your need to add a paremeter equalTo:'#email' to data-validate, Where email is your email address input field's id attribute value. data-validate="{...
Amit Bera's user avatar
  • 77.5k
10 votes

Magento2: How to get guest email address in checkout?

In your custom-method.js file define( [ 'jquery', 'Magento_Checkout/js/model/quote' ], function ($,quote,Component,) { 'use strict'; return Component.extend({ defaults: { ...
Nitesh Kuyate's user avatar
10 votes

how to send custom email no template in magento2?

Original question was about not using template (as I got it) but I'm not sure. Best practice I assume is to use email template. Here is an example of my extension which sends emails every day (...
Fred August's user avatar
10 votes

How to render data type html in template email magento2?

Use |raw with your param variable. example: {{var data|raw}} where data is a param variable that passed to a template and contains a value which is HTML code. data=<html code>
Bhargav Joshi's user avatar
10 votes
Accepted

Magento 2: 'Invalid sender data' While sending custom Email

Try with below code, public function senderEmail($type = null, $storeId = null) { $sender ['email'] = $this->scopeConfig->getValue( self::...
Rakesh Jesadiya's user avatar
10 votes
Accepted

How to style email template in magento2?

Please follow below step to compile email.less copy _email-extend.less folder from vendor/magento/theme-frontend-blank/web/css/source/_email-extend.less and put under app/design/frontend/vendor(...
Satish Rana's user avatar
  • 1,491
10 votes
Accepted

magento2 send email programmatically without template

Magento 2: The simplest way I found to send a plain text - use Zend1 mail $to = ['[email protected]', '[email protected]']; $email = new \Zend_Mail(); $email->setSubject("Feedback email"); ...
Ravi Soni's user avatar
  • 1,809

Only top scored, non community-wiki answers of a minimum length are eligible