-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Enrich contacts with primary company for email token replacement #14944
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
Enrich contacts with primary company for email token replacement #14944
Conversation
Updated Email Preview, Email Send Example, and Send from Contact actions Enriched both real and fake contacts with their primary company information Improved token replacements by ensuring company tokens are available Added prepareFakeContactWithPrimaryCompany() for generating realistic fake contacts
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 7.x #14944 +/- ##
=========================================
Coverage 66.25% 66.25%
- Complexity 35147 35150 +3
=========================================
Files 2314 2315 +1
Lines 141589 141594 +5
=========================================
+ Hits 93809 93814 +5
Misses 47780 47780
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! For Customfields too!
@shinde-rahul please how do I add company-related tokens like {contactfield=companyname} in the email body in step 3? Thank you. |
@imaabasiee, Here is the page containing all tokens that can be used https://docs.mautic.org/en/5.x/configuration/variables.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I fix #12620 I notice issue with company tokens in send custom email. This PR fixed
Code seems legit too 👍
Description
This PR improves how we enrich contact data with company info for email previews, example sends, and regular sends from a contact list or detail page.
It ensures
{contactfield=companyname}
and similar company tokens work reliably, even when there’s no real contact selected.✨ Change log
sendExampleAction
andpreviewAction
to use enriched contacts.prepareFakeContactWithPrimaryCompany()
to create realistic fake contact+company data for previews.User stories
Email Preview
As a marketing user,
I want the contact used in email previews to include the primary company information,
so that I can verify if all tokens, including company tokens, are correctly replaced before sending the email.
Example email
As a marketing user,
I want the example emails I send to myself (or others) to use an enriched contact that includes primary company details,
so that I can test if personalization tokens for contacts and their companies are working correctly.
Send Email from Contact Listing
As a marketing user,
I want to ensure that when sending an email from a contact's listing or detail view, the email uses a contact record enriched with its primary company information,
so that all contact and company tokens populate correctly in the sent email.
📋 Steps to test this PR:
Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
Create a Company and a Contact
→ Associate the contact with the company you just created.
Create an Email
→ Add company-related tokens like
{contactfield=companyname}
in the email body.Check the Preview
→ Open the email in preview mode
→ Try previewing with and without selecting a contact
→ You should see company tokens rendered either way (real or fake data).
Send an Example Email
→ On the Email detail page, use the Edit dropdown → Send Example
→ Check that company tokens are correctly rendered in the received email.
Send Email from Contact Listing
→ Go to the Contact listing page
→ Use the options menu for a contact → Send Email
→ Choose the email and send
→ Confirm company tokens are filled in as expected.