Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3] Fix Store Emails - Missing From Name #18473

Closed
wants to merge 1 commit into from
Closed

[2.3] Fix Store Emails - Missing From Name #18473

wants to merge 1 commit into from

Conversation

gwharton
Copy link
Contributor

@gwharton gwharton commented Oct 8, 2018

The refactoring of the Framework/Mail/Message.php for Magento 2.3 does not implement the second parameter in the setFrom() function.

1st Parameter is email
2nd Parameter (missing) is from address

Description

This PR adds the missing from name to the setFrom function

Fixed Issues (if relevant)

  1. Store emails have correct from address but do not have a from name #18470: Store emails have correct from address but do not have a from name

Manual testing scenarios

  1. Apply [2.3] Alternative fix for Multi Store Emails issue, Fix Async Emails issues, Fix Multiple Email issues #18471 so emails work correctly in the first place
  2. Set a valid from name and from email address for sales contact
  3. Add test product
  4. Purchase test product
  5. Verify that confirmation email has the correct from address and name

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@rogyar
Copy link
Contributor

rogyar commented Oct 9, 2018

Hi @gwharton. Thank you for your contribution. Adding new arguments to public methods is forbidden because of possible backward compatibility issues (https://devdocs.magento.com/guides/v2.2/contributor-guide/backward-compatible-development/#php). Instead of introducing new arguments to public methods you may mark the old method as deprecated and create a new one with all necessary parameters. Thank you

@rogyar rogyar self-assigned this Oct 9, 2018
@gwharton
Copy link
Contributor Author

gwharton commented Oct 9, 2018

Hi @rogyar

I understand the need for that rule, however implementing a new function and deprecating the old one is problematic. I'll explain.

Magento 2.2 code base uses a mixture of setFrom($email) and setFrom($email, $name) calls
Magento 2.2 Framework implements setFrom($email, $name=null)

Magento 2.3 code base uses a mixture of setFrom($email) and setFrom($email, $name) calls
Magento 2.3 Framework implements setFrom($email)

This just looks like a plain mistake in the implementation of the setFrom routine in 2.3.

If I was to add a new function setFromWithName($email, $name) then I would have to go through the entire codebase and find every calling of setFrom($email, $name) and changing it to the new function, further diverging the 2.2 and 2.3 codebases.

I would have thought that common sense in this situation would allow the adding of a "default" parameter to the existing function, as this would mean that nothing would change anywhere else. Existing calls to setFrom($email) would continue unaffected and calls to setFrom($email, $name) would now work as designed.

@rogyar
Copy link
Contributor

rogyar commented Oct 9, 2018

Hi @gwharton. I completely agree with your point. There might be a mistake during the initial implementation.
However, there's a big chance that some 3rd party implementation extends the setFrom method from the original class. In that case, by changing the original public class we can kill the existing stores. That's why we have such strict backward compatibility rules.

@rogyar
Copy link
Contributor

rogyar commented Oct 9, 2018

@magento-engcom-team give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @rogyar. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @rogyar, here is your Magento instance.
Admin access: https://i-18473-2-3-develop.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@brucevalle
Copy link

brucevalle commented Jan 23, 2019

@gwharton could please let me know how to implement this fix on 2.3? We have set our email address mail@myemail.com but the clients got the email from storedep@server.webworksla.com that its a different server email account. Not sure why happen this.

@gwharton
Copy link
Contributor Author

The Pull Request detailing the fix for 2.3.0 can be found here.

#18471

This is scheduled to be included in the 2.3.1 release.

@brucevalle
Copy link

brucevalle commented Jan 23, 2019 via email

@ladle3000
Copy link

@gwharton I patched all my 2.3 files with the PR 18471 and now still have this issue of no FROM NAME.

Can you tell me how I can get that working for my customers as well?

@gwharton
Copy link
Contributor Author

gwharton commented Mar 6, 2019

Hi @snoroozi You're almost there. This PR was combined into PR #18471 so the underlying fix should already be there. Note though, that any third party module that uses the $message->setFrom($emailaddress) function, will need to be updated to use the new $message->setFromAddress($emailaddress, $fromname) function introduced in #18471. Note #18471 updated all Magento functions but third party modules may not have implemented the fix yet, so you will have to do this manually with whichever modules you are using. Search in your modules for "setFrom" and adjust accordingly.

@ladle3000
Copy link

ladle3000 commented Mar 6, 2019 via email

@ladle3000
Copy link

@gwharton Like this?

public_html$ grep -rin 'setFrom' app/
app/code/Mageplaza/GiftCard/Helper/Email.php.orig:233: ->setFrom($sender)
app/code/Mageplaza/GiftCard/Helper/Email.php:234: ->setFrom($sender)
app/code/Mageplaza/GiftCard/Helper/Email.php.modif:234: ->setFrom($sender)
app/code/Infortis/Infortis/view/adminhtml/web/js/jquery/spectrum/spectrum.js:327: textInput.change(setFromTextInput);
app/code/Infortis/Infortis/view/adminhtml/web/js/jquery/spectrum/spectrum.js:329: setTimeout(setFromTextInput, 1);
app/code/Infortis/Infortis/view/adminhtml/web/js/jquery/spectrum/spectrum.js:331: textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
app/code/Infortis/Infortis/view/adminhtml/web/js/jquery/spectrum/spectrum.js:582: function setFromTextInput() {
app/code/Magebird/Popup/Model/Subscriber.php:56: ->setFrom($senderInfo)
app/code/Firebear/ImportExport/view/base/web/js/lib/ace/mode-sqlserver.js:69: "@@DATEFIRST|@@language|CURRENT_TIMESTAMP|DATEADD|DATEDIFF|DATEFROMPARTS|DATENAME|DATEPART|DATETIME2FROMPARTS|DATETIMEFROMPARTS|DATETIMEOFFSETFROMPARTS|DAY|EOMONTH|GETDATE|GETUTCDATE|ISDATE|MONTH|SET DATEFIRST|SET DATEFORMAT|SET LANGUAGE|SMALLDATETIMEFROMPARTS|SP_HELPLANGUAGE|SWITCHOFFSET|SYSDATETIME|SYSDATETIMEOFFSET|SYSUTCDATETIME|TIMEFROMPARTS|TODATETIMEOFFSET|YEAR|" +
app/code/Firebear/ImportExport/Model/Import/Product/Price/Rule.php:17: * @method \Magento\CatalogRule\Model\Rule setFromDate(string $value)

@gwharton
Copy link
Contributor Author

gwharton commented Mar 6, 2019

Are all of your emails missing a from name, or only ones related to Mageplaza gift card/Magebird Popup.

@ladle3000
Copy link

All @gwharton

@ladle3000
Copy link

And here's the vendor directory. But yes, even default magento emails are still missing
vendor.txt

@ladle3000
Copy link

Any thoughts @gwharton

Mageplaza has offered up a fix in their smtp module that addresses most of these issues, but also some custom extensions not working. Maybe for same reason you say here.

@ladle3000
Copy link

It seems mageplaza's solution is to reset the setFrom name function as a workaround in place of patching 2.3.

Still it seems strange that none of my emails were working correctly after I did have this patch applied previously, don't you think? Or is it possible 3rd party modules could be interfering outside of their own module in the same way that amazon modules were affecting things for some merchants?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants