Magento 2 Email Showing template hints - email

I'm in production mode and a custom module is sending the template hints. Here is an example of a template hint above a block:
/var/www/html/website.com/vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml
Here is the line of code to send the email:
$this->shipmentSender->send($shipment);
Other modules use essentially the same code to send notifications and don't have this problem.

Firstly I used $state->setAreaCode('frontend');, but email template has debug hints. After this I used $state->setAreaCode('global'); and email tamplate hasn't debug hints.
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('global');
$this->shipmentSender->send($shipment);
I try this on Magento 220

Related

Mail stay in queue when i use Sendgrid in symfony6

I have set my Sendgrid single sender and validate it ( status = verified).
I use SMTP, create my key that i paste in my code (.env file of my app):
MAILER_DSN=sendgrid+smtp://#default
Then i try to test integration in Sendgrid by clicking on button and refresh my localhost/ page (of course the controller's route is "/" and it contains the code using mailer to send a mail as explain in mailer documentation).
On my vue i don't have error code but mail stay in queue status...
Here the screenshot taken of the profiler:
Can someone tell me why my mail stay queued?
Of course the From email address is mine ( the verified one) and the To is anotherone of mine.
Maybe i have to configure something in my outlook mail (the From one) ?
Sendgrid never match the verification, it stay in checking status until message :
Hmm, we haven't seen your email yet.
Please check your code, run it again, then click "Retry".
Thanks for reply,
Regards,
In your question you said that your MAILER_DSN environment variable is set to:
MAILER_DSN=sendgrid+smtp://#default
That is missing your API Key though. You need to create an API key in the SendGrid dashboard and then add the API key to the MAILER_DSN variable, between the // and the #default like this:
MAILER_DSN=sendgrid+smtp://API_KEY#default
One other thing, ensure that you have installed the SendGrid transport with this command:
composer require symfony/sendgrid-mailer
Yes, thanks you a lot for reply.
Of course all was set as you notify me.
I now have fix my issue, in fact the problem for me with the mail that remains in queued is that the messenger was installed so in asynchronous by default.
I had to add the option message_bus: false in my config/packages/mailer.yaml file not to have the asynchronous option used.
Hopefully this is useful for some people.
add the option message_bus: false in my config/packages/mailer.yaml:
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
message_bus: false

Magento and mandrill smtp headers

I am using Mandrill as a SMTP.
It is successfully connected to Magento 2.
My question :
Is it possible to use Mandrill's custom header references through Magento Email Templates.
For example, I have created custom templates in Mandrill that can be called upon by a customized field in the email header.
Usually it can be added the same way as the reply-to field.
I want to use the following functionality below:
https://mandrill.zendesk.com/hc/en-us/articles/205582117-How-to-Use-SMTP-Headers-to-Customize-Your-M...
Can I add in the header template :
<?php
$headers = $this->getHeaders();
$headers->addTextHeader('X-MC-Template', 'template_name');
?>
Any guidance would be greatly appreciated.
Thanks
You can create your own plugin for Magento (as it was done in the mageplaza/magento-2-smtp extension, they have shared their experience here) that will help you to rewrite the send mail function sendMessage () through the aroundSendMessage () function. In this case you can write headers on your own depend on the message.
How to create a plugin for Magento 2 you can find at Magento official documentation: https://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

I use magento 2, when submit contact form then issue on mail

I use magento 2, when submit contact form then issue on mail, when receive successfully but problem is apostrophe character.
Suppose any Customer write comment like: Can't able to login then in mail
display like: Can &#039 ; t able to login
I use 4-5 latest version all version this common issue,
Please help to resolve if you know
Go to this path "/vendor/magento/module-contact/view/adminhtml/email" and open "submitted_form.html" and replace 19th line code with the below-mentioned code
{{trans "Comment: %comment" comment=$data.comment|raw}}
Adding to the comment of Abhinav Kumar Singh, there's another way for those who are working with copies of the default e-mail templates in admin backend: MARKETING > COMMUNICATIONS > E-MAIL TEMPLATES.
No need to override original Magento files.
After you have imported the Contact-Form Template, you will find the same syntax in the Template Content field. Just add the "|raw" tag there.
{{trans "Comment: %comment" comment=$data.comment|raw}}
or
{{var data.comment|raw}}

Joomla extension, JomSocial: Removing the welcome email upon registration

On Joomla! 2.5.4 I'm using the JomSocial 2.6.0 extension. Looking for the code that is sending the first registration notification email "welcome email containing username+password" so that I can remove it.
Currently there are two emails sent upon registration, the first which contains the username and password, second that contains the verification link. However I think that having two emails is totally unnecessary.. Thanks!
I found the code from com_community/controllers/register.php
$this->_sendEMail('registration_uncomplete', $tmpUser, $password);
Is it safe or a good idea to just null this?
//$this->_sendEMail('registration_uncomplete', $tmpUser, $password);
$var = NULL;
seems to be working...

Force.com email service

I have created an email service in force.com.Can anyone help me out of how to use thta in apex classes.say,i wanna send mail when user registration is successful??
Many Thanks,
Sandhya Krishnan
I assume you want to send an email directly from Apex code, either in a Trigger or from a page controller ... ? If so, this page can get you started:
http://www.forcetree.com/2009/07/sending-email-from-your-apex-class.html
Clearly you don't want to hard-code your email template into your classes, so make sure to read at least through the part that shows how to look up the template dynamically. That should be enough to get you on your way.