We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have used the following example: https://github.com/sendgrid/sendgrid-php/blob/main/USE_CASES.md#send-multiple-emails-with-personalizations
<?php // Uncomment next line if you're not using a dependency loader (such as Composer) // require_once '<PATH TO>/sendgrid-php.php'; use SendGrid\Mail\From; use SendGrid\Mail\Mail; use SendGrid\Mail\Personalization; use SendGrid\Mail\Subject; use SendGrid\Mail\To; $from = new From("[email protected]", "Twilio Sendgrid"); $to = new To( "[email protected]", "Example User1", [ '-name-' => 'Example User 1' ], "Example User1 -name-" ); $subject = new Subject("Hello from Twilio Sendgrid!"); $plainTextContent = new PlainTextContent( "How's it going -name-?" ); $htmlContent = new HtmlContent( "<strong>How's it going -name-?</strong>" ); $email = new Mail($from, $to, $subject, $plainTextContent, $htmlContent); $personalization0 = new Personalization(); $personalization0->addTo(new To( "[email protected]", "Example User2", [ '-name-' => 'Example User 2' ], "Example User2 -name-" )); $personalization0->addTo(new To( "[email protected]", "Example User3", [ '-name-' => 'Example User 3' ], "Example User3 -name-" )); $personalization0->setSubject(new Subject("Hello from Twilio Sendgrid!")); $email->addPersonalization($personalization0); $personalization1 = new Personalization(); $personalization1->addTo(new To( "[email protected]", "Example User4", [ '-name-' => 'Example User 4' ], "Example User4 -name-" )); $personalization1->addTo(new To( "[email protected]", "Example User5", [ '-name-' => 'Example User 5' ], "Example User5 -name-" )); $personalization1->addFrom(new From( "[email protected]" => "Twilio" )) $personalization1->setSubject(new Subject("Hello from Twilio!")); $mail->addPersonalization($personalization1); $sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY')); try { $response = $sendgrid->send($email); print $response->statusCode() . "\n"; print_r($response->headers()); print $response->body() . "\n"; } catch (Exception $e) { echo 'Caught exception: '. $e->getMessage(). "\n"; }
The emails are sent, but for each Personalizations ([email protected], [email protected], ..., [email protected]) the "-name-" tokens are not replaced neither in the content nor in the subject. The token is replaced correctly for the email to "[email protected]".
In conclusion, token replacement does not work in Personalizations.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have used the following example: https://github.com/sendgrid/sendgrid-php/blob/main/USE_CASES.md#send-multiple-emails-with-personalizations
The emails are sent, but for each Personalizations ([email protected], [email protected], ..., [email protected]) the "-name-" tokens are not replaced neither in the content nor in the subject. The token is replaced correctly for the email to "[email protected]".
In conclusion, token replacement does not work in Personalizations.
The text was updated successfully, but these errors were encountered: