Sendgrid-php: Duplication of sent emails

Created on 29 Oct 2017  路  4Comments  路  Source: sendgrid/sendgrid-php

Duplication of sent emails

When using the same email in $to param in \SendGrid\Mail::__construct and SendGrid\Personalization::addTo() the send grid count the sent email twice instead of counting it one time

#### Steps to Reproduce\
When you try add cc or bcc using new pesrsonalization
$personalization = new \SendGrid\Personalization();
$to = new \SendGrid\Email("", '[email protected]');
$email = new \SendGrid\Mail( $from , $subject , $to , new SendGrid\Content("text/html", $body));
$personalization->addBcc(new SendGrid\Email("", $bcc));
$email->addPersonalization($personalization);
$sendgrid = new \SendGrid($key)
$response = $sendgrid->client->mail()->send()->post($email);

Technical details:

  • sendgrid-php Version: 6.0
  • PHP Version: 5.6
medium waiting for feedback question

Most helpful comment

It happens the same to me as well. However checking out the request body, I got to know that I add $to twice like the below.

first one.
$mail = new SendGrid\Mail($from, $subject, $to, $content);

and second one.
$personalization = new SendGrid\Personalization();
$personalization->addTo($to);

It sends twice because I added twice.
Please check if yours works as like mine does.

All 4 comments

Same happening for me but different usage so will post new issue.

Hi @elshafey,

Could you please print out your request body so I can try and reproduce?

@CostaC,

Please reference this issue in your new issue.

Thanks!

With Best Regards,

Elmer

It happens the same to me as well. However checking out the request body, I got to know that I add $to twice like the below.

first one.
$mail = new SendGrid\Mail($from, $subject, $to, $content);

and second one.
$personalization = new SendGrid\Personalization();
$personalization->addTo($to);

It sends twice because I added twice.
Please check if yours works as like mine does.

Thanks for providing some additional feedback @kabkee!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

micahwalter picture micahwalter  路  3Comments

izhukovich picture izhukovich  路  4Comments

solonifer picture solonifer  路  3Comments

moontrv picture moontrv  路  3Comments

peluprvi picture peluprvi  路  5Comments