-
Notifications
You must be signed in to change notification settings - Fork 623
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
NULL Item in Personalizations #686
Comments
Good catch @mlammert! I've added this to our backlog for further investigation. When you use the constructor, we create a default personalization object for you. I believe that is probably the source of this odd behavior. With Best Regards, Elmer |
So, I know inserting the from address in the mail constructor seems to get rid of the NULL item. However, that seems sort of "hack-ish" to me. Is there a better recommended way to remove the NULL item from the personalziation array? Thanks! |
I agree @mlammert, this is not expected behavior. This issue is currently on our backlog for an investigation and fix. Thanks! |
Did some debugging here: If there’s no parameters passed to \SendGrid\Mail\Mail constructor, it initiates personalization attribute with an empty Personalization instance immediately followed by a return.
I couldn’t see any specific reason for initialising like this. Please correct me if I’m wrong here. If this initialisation is removed the above mentioned issue will get resolved. Please let me know as I’m happy to help here. |
Hi @remyapv, I believe the purpose of that initialization was to make sure there was at least on personalization created when you create a But I think you are right, by doing that we cause more confusion and our Kitchen Sink example would not work properly. This issue is all yours :) Thanks! With Best Regards, Elmer |
@thinkingserious can you please take a look at the patch? |
currently migrating from 5.0.4 to 7.3.0. searched for hours, and this solved my the doc didnt give me any hints for that. 😕 |
Fixed by #705 |
Issue Summary
We are sending the same individual email to 100s/1000s of users with substitutions so that certain parts of the email are unique to the individual recipient.
I believe my logic is sound and as you will see below the resulting JSON payload look correct, except for one thing. The first item in the personalizations array is NULL.
Steps to Reproduce
Here is some truncated code that we are using. Since SendGrid can only process 1,000 emails at a time, we chunk the returned array of users from the database into separate arrays. So, for example, if we have to send 3,000 emails, this will chunk into 3 ($i) and then the personalization will loop through the users in those chunks ($j). This will result in making 3 requests of 1,000 personalized emails.
This all works great.
The trouble comes when I view the JSON of the $objMail. Here is a truncated example of the JSON payload I get.
The JSON payload looks correct except for the first NULL item personalization array.
Does anybody know why the NULL is being inserted?
Thanks!
EDIT: I just noticed the person in ISSUE #650 was having a very similar issue to me with the NULL personalization item. I implemented the fix (inserting a from address in the mail constructor) and it seems to have worked.
My question now is why does the NULL issue happen? And, how does inserting a from address into the mail constructor fix it? Nowhere in any docs have I seen the from address inserted directly into the mail constructor.
Technical details:
The text was updated successfully, but these errors were encountered: