Skip to main content

deliver_in

Function deliver_in 

Source
pub fn deliver_in(
    ctx: &Ctx,
    email: Email,
    delay: Duration,
) -> impl Future<Output = Result<()>> + Send + use<>
Expand description

Checks email now and sends it from the jobs queue after delay, like Rails’ deliver_later(wait:).

Works like deliver_later, with the message due after delay (whole seconds, 24 hours at most, Queues’ limit): a reminder an hour after sign-up, a digest at the end of the day. Same free-plan cost as deliver_later.

§Errors

Those of deliver_later, plus an Error::Internal when delay is over 24 hours.

§Examples

use std::time::Duration;

use ocre::mail::Email;

async fn remind(ctx: &ocre::Ctx) -> ocre::Result<()> {
    let email = Email::new("ada@example.com", "Finish setting up your shop", "https://example.com/setup");
    ocre::mail::deliver_in(ctx, email, Duration::from_secs(3600)).await
}