magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Confirmation emails have no FROM or FROM email address 2.2.4 #14952

Closed tstamplis closed 5 years ago

tstamplis commented 6 years ago

Preconditions

Magento 2.2.4 PHP 7.1 Cpanel Server

Steps to reproduce

Production Mode Single Store Mode Add product to cart Checkout

Expected result

Order confirmation email with FROM name and email address sent to customer per settings from store email addresses in config

Actual result

Order confirmation email contains no FROM or FROM EMAIL address.

SamB-GB commented 6 years ago

I can confirm I am also seeing this issue. In order to work around the problem I have had to force the FROM header from the php.ini file.

sendmail_path= "/usr/sbin/sendmail -t -i -f enter@emailaddresshere.com"

chequille commented 6 years ago

Have the same issue: Ticket #14945

andy17612 commented 6 years ago

@SamB-GB So need to add the mine mail in the php.ini ?thank you

chequille commented 6 years ago

Hi @SambB-GB, I guess this is a misunderstanding. gwharton closed my issue "Store Email Adresses are not used anymore" because it is the same as this one. It does not mean, that there will be no soultion for it.

Correct gwharton ? BR Chequille

gwharton commented 6 years ago

@chequille yes. The solution to both will be tracked under this issue. Having it tracked in two places will just lead to confusion.

SamB-GB commented 6 years ago

Yes thats correct @rigu12

gwharton commented 6 years ago

This is the commit that introduced this bug.

https://github.com/magento/magento2/commit/f2bfdd941c0c8c6c7c745156d1ce206e38c76820

Broken during fix applied for #11740

If you manually revert the changes in files according to that commit, you can get back to pre bug status.

app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

@RomaKis What was this commit trying to achieve?

jsdupuis commented 6 years ago

Facing the same issue here in Magento 2.2.4. We have one website with 2 stores (Thai + English).

ozziel commented 6 years ago

I had the same issue. after 2.2.3 >2.2.4 update. We have 4 websites with 2 stores each.

I did as gwharton suggested, I used the 2 files from 2,2,3 and it's working correctly now from what I can tell.

Thank you!

andy17612 commented 6 years ago

so 2.2.4 recover 2.2.3 this file?? @ozziel app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

ozziel commented 6 years ago

You will have to recover them from their source folders: NOTE: if you can't tell your restore function where to restore files and it restores them to the original path BE SURE TO BACKUP ORIGINALS ALREADY THERE FROM 2.2.4 before restoring vendor/magento/module-sales/Model/Order/Email/SenderBuilder.php vendor/magento/framework/Mail/Template/TransportBuilder.php

and then create the above folders and put them there app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Keep in mind that this overrides magento default functions so if and when the corrections are made, you will need to remove these to use default functions again.

Hope this helps.

jsdupuis commented 6 years ago

I did as ozziel suggested (thanks for pointing to the vendor folder where my files were) and it fixed the problem.

littlescrat commented 6 years ago

Correct. The fix by @ozziel worked for me too. I hope there will come up a patch for this issue.

sashas777 commented 6 years ago

Have you tried to switch to any SMTP module if it would fix the issue until Magento patch will be available?

littlescrat commented 6 years ago

I have installed the module "Mageplaza_Smtp" and i tried "MagePal_GmailSmtpApp". Both gave me a blank from-sender. But that is obvious, because the problem is much further in the procedure. See answer from ozziel, the paths.

sashas777 commented 6 years ago

Guys I made quick extension and forced it to be used only on Magento 2.2.4 version assume that bugfix will be in the next release. I tested and it works on my websites. I hope it can help you as well: https://github.com/sashas777/bug-from-email

You can install it using composer and then remove when will be new Magento 2 release. If you will forget to remove then you will have version compatibility error with any other Magento 2 release.

rav-redchamps commented 6 years ago

The problem is they created a new class

Magento\Framework\Mail\Template\TransportBuilderByStore

and correctly added FROM header to member "message" of the class.

But the "message" member of TransportBuilderByStore never used. Instead, the member "message" of the class TransportBuilder is getting used(which never updated with FROM email).

Moral of the story, they added FROM email correctly but never used it while sending the email.

The tiny extension by @sashas777 does the required job as of now.

@sashas777 Good Job!! Just one suggestion, it would be better if you can rename the folder 'Plugin' to 'Rewrite' or something else. Because the fix is done using class rewrite instead of the plugin. The folder name "Plugin" misleads ;-)

rav-redchamps commented 6 years ago

@sashas777 I did the required change and created a pull request. Please merge it if it makes sense :smiley:

sashas777 commented 6 years ago

@ravinders-121

Thanks - I updated the package.

robertkent commented 6 years ago

@sashas777 fixed it for me too - weird how such an important part can break so easily! No Sender means you get bounce-backs from any Gmail account at the very least

pfortin-expertime commented 6 years ago

Hi guys,

a small module to fix it without touching the core:

https://github.com/pfortin-expertime/MageFix-Misc

msawyers commented 6 years ago

A simple fix instead of installing a module is to do like below until fixed in next release:

Goto >. ..../vendor/magento/module-sales/Model/Order/Email/SenderBuilder.php Edit function configureEmailTemplate() and add this line $this->transportBuilder->setFrom($this->identityContainer->getEmailIdentity()); to show like below: protected function configureEmailTemplate() { $this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId()); $this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions()); $this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars()); $this->transportBuilder->setFrom($this->identityContainer->getEmailIdentity());

//the below are commented
//$this->transportBuilderByStore->setFromByStore(  
//    $this->identityContainer->getEmailIdentity(), 
//    $this->identityContainer->getStore()->getId() 

// ); }

gwharton commented 6 years ago

Ive removed this revert from my store and gone back to the release version and it is now working fine. I have no idea why so many are seeing this issue anymore. However leaving the release code in place causes any function that sends multiple emails in one operation to send only the first, the remaining emails fail with exception.

sashas777 commented 6 years ago

@msawyers Edit the core

msawyers commented 6 years ago

@sashas777

I did this: copy from the previous version to: app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

gwharton commented 6 years ago

If anyone can reproduce this issue on demand, could they please attempt to diagnose/trace this issue by debug as I am no longer able to reproduce it. If anyone has this fault on a dev install, and would be ok with me connecting remotely to their install to debug then that would be great also. Get in touch.

I have deployed various test stores, vanilla 2.2.4, and 2.2.3 upgraded to 2.2.4 and all work faultlessly.

chequille commented 6 years ago

@gwharton sorry, but on my page when I use the code for app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php from the release, the problem still exists.

Why should it work now, if nothing was changed in the code?

There is no new release, therfore, I really do not understand what you are talking about. Fact is: 2.2.4 is not using Store Email Adresses and Names when sending EMails.

BR Chequille

gwharton commented 6 years ago

I upgraded from 2.2.3 to 2.2.4 and it stopped working. I reverted the code to 2.2.3 and it started working again. I changed code back to 2.2.4 and it still works. I deploy fresh 2.2.4 and it works.

I dont know whats going on either.

sashas777 commented 6 years ago

@gwharton

You can use temporary patch https://github.com/sashas777/bug-from-email It easy to install and it will ask you to do uninstall after the upgrade

hostep commented 6 years ago

@gwharton, just guessing here: you didn't apply any other patches for 2.2.4 which might seem unrelated to this one? Maybe one of those other patches fixes this issue as well somehow ...

ramindas commented 6 years ago

Same issue here,from address blank in sales email and SMTP server is not allowing to relay.

Sales email blank from address

Please help to fix the issue

Thanks

EliasKotlyar commented 6 years ago

Encountered this issue as well in a 2.2.4. Fixxed with the solution from @gwharton .

Goeny commented 6 years ago

@sashas777 Great job on the little plugin. Only problem is: Mageplaza PDF invoices breaks after installing the fix.. :-(

sashas777 commented 6 years ago

@Goeny What error does it give?

Goeny commented 6 years ago

@sashas777 It doesnt give an error. It simply does not send the PDF's along with the mail anymore. Can't see any error's in logs anywhere.

hostep commented 6 years ago

@gwharton:

I upgraded from 2.2.3 to 2.2.4 and it stopped working. I reverted the code to 2.2.3 and it started working again. I changed code back to 2.2.4 and it still works. I deploy fresh 2.2.4 and it works. I dont know whats going on either.

Have you by any chance disabled the Amazon Pay module in 2.2.4? There is a report which claims that the Amazon Pay module causes this problem.

chequille commented 6 years ago

I really wonder why reverting to 2.2.3 and upgrade to 2.2.4 worked. Not on my site. Disabling Amazon Payment is causing an error, therefore cannot be the case why it is working.

hostep commented 6 years ago

@chequille: I just tested this myself, and you are right, only disabling Amazon_Payment causes a problem, because the Amazon_Login module also references the payment module in its config.xml file.

So then I tried the same with disabling both: Amazon_Payment & Amazon_Login as follows:

bin/magento module:disable Amazon_Payment Amazon_Login

And now my sales emails have a correct sender set:

screen shot 2018-06-24 at 17 29 04

So it looks like this bug has appeared since those Amazon modules got included by default in Magento 2.2.4, the question is: is it because the thing @kingyond mentioned:

vendor/amzn/amazon-pay-and-login-magento-2-module/src/Payment/etc/di.xml find this line 63 <type name="Magento\Framework\Mail\MessageInterface" shared="false" /> remove the shared string <type name="Magento\Framework\Mail\MessageInterface" />

Or is it because when those Amazon modules do this, that it triggers a previously hidden bug in Magento itself...

gwharton commented 6 years ago

This does make sense come to think of it. I recently moved from composer install to github install. When installing via github, you don't seem to get any of the amazon modules by default in 2.2.4 which explains why I can no longer reproduce this issue.

chequille commented 6 years ago

Hi Again, disballed Payment and Login and as expected: it is working again correct. So, question is now, Where is the bug, in Magento or Amazon ?

gwharton commented 6 years ago

The poorly implemented fix in #11740 exposed the bug in the Amazon module.

robolmos commented 6 years ago

Should this bug be mentioned in both 2.2.4 and 2.2.5 release notes known issues? And work-arounds?

versdivers commented 6 years ago

If you want a fix https://github.com/magento/magento2/compare/2.2-develop...versdivers:Fix-EmailSender

vivekaris commented 6 years ago

this Issue exist in magento 2.2.5

vivekaris commented 6 years ago

https://github.com/sashas777/bug-from-email

@sashas777 its not working in magento 2.2.5. good for magento 2.2.4 on magento 2.2.5 Your module says require magento 2.2.4

gwharton commented 6 years ago

@vivekaris. Disable the amazon payments module as a workaround.

sashas777 commented 6 years ago

@vivekaris packaged version updated

paul-blundell commented 6 years ago

Had this same problem in 2.2.5, I was able to get around it by disabling Amazon Pay with the following:

php bin/magento module:disable Amazon_Core Amazon_Login Amazon_Payment

I wish Magento would stop preinstalling stuff we might not need!

maderlock commented 6 years ago

@paul-blundell Don't hold your breath. This is obviously a change of direction in order to monetise Magento. They've got to do it some how, and we as a community keep on creating extensions that make the enterprise features seem a little minimal for the fee.

In the meantime, it looks like the https://github.com/sashas777/bug-from-email module has been updated to allow the module to run in 2.2.5.

If you really want to stop modules being included when pulling in via composer, you can add something like this to your composer.json (untested for this specific modue btw):

"replace": {
      "amzn/amazon-pay-and-login-magento-2-module": "*"
}
rishabhchd19 commented 6 years ago

YES, it is confirmed that problem resolved by disabling Amazon Payment.