-
Notifications
You must be signed in to change notification settings - Fork 625
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
Personalization missing functions #1080
Comments
For the second issue, it has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog. For the first issue, could you provide a code sample for what the issue is that you're seeing? That will help to understand what's going on. |
If you want to send a newsletter, for example, you want to have the same headers for all the emails: $email = new \SendGrid\Mail\Mail();
$email->addHeader('List-Unsubscribe', "<$link>");; // <-- this created an empty Personalization object
...
foreach($subscribers as $subscriber)
{
$personalization = new Personalization();
$personalization->addTo(new To($subscriber->email, ""));
,,,
}
// throws an error because first $email->addHeader() creates an empty
// Personalization object without defined "to" field
$response = $sendgrid->send($email); Take a look at addHeader from public function addHeader(
$key,
$value = null,
$personalizationIndex = null,
$personalization = null
) {
$header = null;
if ($key instanceof Header) {
$h = $key;
$header = new Header($h->getKey(), $h->getValue());
} else {
$header = new Header($key, $value);
}
$personalization = $this->getPersonalization($personalizationIndex, $personalization);
$personalization->addHeader($header);
} You see? It creates an empty Solution? I have to add the same headers to every Unproductive and bad design. Hard to spot and debug. Even your own documentation is wrong at this: https://docs.sendgrid.com/for-developers/sending-email/personalizations `Some properties can be defined both at the root level of the request body (message level) and at the personalizations level. For example, the from, subject, headers, custom_arg, and send_at properties can all be defined at the message level or at the personalizations level. ` |
Ah, I see. Definitely an issue. Will add that to the backlog as well. PRs are welcome. |
1st bug
Adding header to the message before adding personalization, creates an empty personalization object within the email object, and when you add following personalization with recipients emails, your interface throws error because the first personalization initialized by adding header doesn't contain TO field! Who wrote this code??? Seriously, this is bad design decision...
2nd I dunno missing feature
doesn't work like we do it for the single email, we need to do:
just add wrapper to handle it like it's done for the
$email->addHeader(key, value)
The text was updated successfully, but these errors were encountered: