Skip to content

[Mailer][SendGrid] add support for scheduling delivery via send_at API parameter #60372

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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
from

Conversation

MrMitch
Copy link

@MrMitch MrMitch commented May 7, 2025

Q A
Branch? 7.3
Bug fix? no
New feature? yes
Deprecations? no
Issues N/A
License MIT

This PR adds support for scheduling delivery when using the SendGrid API transport (with a sendgrid+api DSN), by providing a \DateTimeInterface object in a Symfony\Component\Mime\Header\DateHeader named Send-At.

$email = new \Symfony\Component\Mime\Email();
$email->getHeaders()->addDateHeader('Send-At', (new \DateTime())->modify('+3 hours'));

It will be mapped to the send_at parameter of the [POST] /mail/send API endpoint.

@carsonbot carsonbot added this to the 6.4 milestone May 7, 2025
@carsonbot carsonbot changed the title [Mailer][SendGrid] add support for scheduling delivery via send_at API parameter [Mailer] [SendGrid] add support for scheduling delivery via send_at API parameter May 7, 2025
@MrMitch
Copy link
Author

MrMitch commented May 7, 2025

Test failures look unrelated

@OskarStark OskarStark modified the milestones: 6.4, 7.3 May 7, 2025
@OskarStark
Copy link
Contributor

New features need to target the newest branch, which is 7.3

@OskarStark OskarStark changed the title [Mailer] [SendGrid] add support for scheduling delivery via send_at API parameter [Mailer][SendGrid] add support for scheduling delivery via send_at API parameter May 7, 2025
}
// the documentation shows parameter names in camelCase but the expected JSON keys should be in snake_case
$payload['send_at'] = $header->getDateTime()->getTimestamp();
} elseif ($header instanceof TagHeader) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,thank you for your suggestion.
I didn't want to change too much of the code to facilitate the review process but I'll gladly update the successive conditions if necessary. Is it something you would like me to do in this PR ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a suggestion, but since you've added new conditions, this approach might make sense, as it's used in other integrations. I think it's worth waiting to hear and consider other opinions before making a final decision.

@carsonbot carsonbot changed the title [Mailer][SendGrid] add support for scheduling delivery via send_at API parameter [Mailer] [SendGrid] add support for scheduling delivery via send_at API parameter May 8, 2025
@MrMitch MrMitch force-pushed the sendgrid-mailer-date-send-at branch from 50ac018 to a317491 Compare May 8, 2025 10:39
@MrMitch MrMitch changed the base branch from 6.4 to 7.3 May 8, 2025 10:39
@MrMitch
Copy link
Author

MrMitch commented May 8, 2025

@OskarStark @bkosun Thank you for your feedback, I've applied all the suggested changes. Let me know if you would like me to make additional changes.

@stof
Copy link
Member

stof commented May 16, 2025

Is this Send-At header supported by their SMTP server ?

@MrMitch
Copy link
Author

MrMitch commented May 16, 2025

Hi @stof,

Yes, the Send-At header is supported by their SMTP server as well, as per the documentation :

You can use the SMTP API header to schedule your emails when sending via SMTP or our mail.send API endpoint.

@OskarStark OskarStark changed the title [Mailer] [SendGrid] add support for scheduling delivery via send_at API parameter [Mailer][SendGrid] add support for scheduling delivery via send_at API parameter May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants