Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 9f9ff75a authored by Nivesh Krishna's avatar Nivesh Krishna
Browse files

only delay welcome email

parent 5d2a86b3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -328,8 +328,8 @@ function sendWelcomeMailWithSendGrid(string $to, string $mbox, string $domain, s
      new \SendGrid\Mail\Substitution("display_name", $displayName),
    ];


    $email = createSendGridEmail($to, $TEMPLATE_ID, $substitutions);
    $delay = time() + 30;
    $email = createSendGridEmail($to, $TEMPLATE_ID, $substitutions, $delay);

    sendEmailWithSendGrid($email);
}
+2 −2
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ function getLocalizedEnv(string $envKey, string $lang): string
    return $value;
}

function createSendGridEmail(string $to, string $templateId, ?array $substitutions): \SendGrid\Mail\Mail
function createSendGridEmail(string $to, string $templateId, ?array $substitutions, ?int $delay = 0): \SendGrid\Mail\Mail
{
    $SEND_FROM = getenv("SENDGRID_EMAIL_FROM");
    if ($SEND_FROM === false) {
@@ -217,7 +217,7 @@ function createSendGridEmail(string $to, string $templateId, ?array $substitutio
        $email->addDynamicTemplateDatas($substitutions);
    }
    $email->setTemplateId($templateId); 
    $email->setSendAt(time() + 60); // send mail after 1 minute
    $email->setSendAt($delay); // send mail after $delay
    return $email;
}