# Scheduled Emails & Timezone - Understanding & Strange Behaviours

**URL:** <https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371>\
**Category:** Product Support\
**Created:** [June 20, 2023, 6:55am UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371 "2023-06-20T06:55:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [June 20, 2023, 6:55am UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/1 "2023-06-20T06:55:14Z")

</div>

**Your software**  
My Mautic version is: 4.4.4  
My PHP version is: 7.4

**Your problem**  
My problem is:

When you have a campaign with a Send Email scheduled for a specific time like 7pm UTC, it is not sent to all the users at 7pm UTC.

So some investigation and points to note. After realizing that certain users are getting the emails at the wrong time we started diving into this to understand what is going on here.

1. We checked the systematize some on the server and verified it is set to UTC. This is important for your cronjob as they will run according to system time.
2. We checked the TimeZone of the user that is logged in and verified that their timezone is set inside Mautic to UTC. If it is not set to UTC, but rather another time zone, the email will be sent out at the users time zone regardless of what Mautic default timezone is set to.
3. Verified that timezone in php.ini is set to UTC.

Then we went and setup a campaign with an action to send an email at 5pm UTC (for example).  
Added a bunch of users to the campaign, updated the campaign and triggered the campaign.  
Went to inspect the users contact cards and noticed that some users had events scheduled to 5pm UTC but others had the same event scheduled for different UTC times… This seemed strange.

Opened user cards and noticed that certain users did not have “Preferred Timezone” set and some did.  
For those without “Preferred Timezone” the message where scheduled to go out at specified time UTC, however for the ones that had it set their scheduled send time was different and not conforming to time change conversions.

For example:  
User TimeZone set to Jerusalem/Israel, the mail is scheduled to go out at 2am UTC. Israel is +3 UTC, so it should really be scheduled to go out at 8am.  
User TimeZone set to America/New\_York, the mail is scheduled to go out at 9am UTC. America/New\_York is UTC -4, so this should go out at 1am

It looks like my understanding of the logic here is a bit backwards, so maybe someone can shed some light on the matter (@joeyk 😉 ).

Next question is how and when is the Preferred TimeZone set because I see it for some users and not for others.

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [June 26, 2023, 11:13am UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/2 "2023-06-26T11:13:21Z")

</div>

bumping this up with the hope that someone can chime in here. Is there anyway to override the timezone settings for all contacts so that it does not get updated?

---

<div class="post-metadata">

**Author:** ![IonutOjicaDe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ionutojicade/32/7383_2.png) [@IonutOjicaDe](https://forum.mautic.org/u/IonutOjicaDe)\
**Post date:** [June 27, 2023, 9:32pm UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/3 "2023-06-27T21:32:05Z")

</div>

Hi Mike, does this comment clarify something?

> [@Sending email at a specific time according to the time zone mentioned in the contact profile](https://forum.mautic.org/t/sending-email-at-a-specific-time-according-to-the-time-zone-mentioned-in-the-contact-profile/25790/3):
>
> Info I learned: Segment Emails (Newsletters) are sent according to Mautic Timezone (Author Timezone) Campaign Emails are sent according to contact Timezone Is the “Preferred Timezone” a custom contact field? Or is the default one that is used also by Mautic, when sending Campaign Emails?

Note: I used at first UTC inside Mautic. This was wrong, as this one does not consider Summer-Time. I changed to Berlin and it works ok.

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [June 28, 2023, 1:01pm UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/4 "2023-06-28T13:01:52Z")

</div>

Hi @IonutOjicaDe thanks for the reply. Yes I understand the current behaviour and how Mautic is dealing with both user and contact timezone, what I am looking to see if there is a way to override the preferred timezone as we would like all RSS emails going out at a specific UTC time irrespective of the contacts timezone.

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [June 28, 2023, 2:23pm UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/5 "2023-06-28T14:23:09Z")

</div>

Well it drove me mad, but finally found how to comment this setting out and stop the system from sending at contacts preferred timezone (if set).

In order to remove the sending of an email to a contact at his preferred timezone, need to do the following:

1. Make a copy of the file before doing anything
2. Edit file /var/www/mautic/app/bundles/CampaignBundle/Executioner/Scheduler/Mode/Interval.php
3. Comment out lines 245 through to 262

Here is the code block:

```auto
  // Set execution to UTC
        if ($timezone = $contact->getTimezone()) {
            try {
                // Set the group's timezone to the contact's
                /** Commented out in order to remove sending at contacts preferred timezone 
                $contactTimezone = new \DateTimeZone($timezone);

                $this->logger->debug(
                    'CAMPAIGN: ('.$eventId.') Setting '.$timezone.' for contact '.$contact->getId()
                );

                // Get now in the contacts timezone then add the number of days from now and the original execution date
                $groupExecutionDate = clone $compareFromDateTime;
                $groupExecutionDate->setTimezone($contactTimezone);

                $groupExecutionDate->add($diff);

                $groupExecutionDate->setTime($groupHour->format('H'), $groupHour->format('i'));

                return $groupExecutionDate;
                **/
            } catch (\Exception $exception) {
                // Timezone is not recognized so use the default
                $this->logger->debug(
                    'CAMPAIGN: ('.$eventId.') '.$timezone.' for contact '.$contact->getId().' is not recognized'
                );
            }
        }

```

---

<div class="post-metadata">

**Author:** ![IonutOjicaDe](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ionutojicade/32/7383_2.png) [@IonutOjicaDe](https://forum.mautic.org/u/IonutOjicaDe)\
**Post date:** [June 28, 2023, 5:14pm UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/6 "2023-06-28T17:14:32Z")

</div>

Hey, great workaround ! Thank you for your tip.

Of course, it would be better if each email (segment or campaign email) could have a boolean setting: according to contact timezone or to owner timezone.

But, until then, how could we achieve this one? Let’s say, if we include a specific text inside “Internal Name” of the email that we can check in the code and act accordingly?

**Later edit:**  
Here ist the Feature request:

> [@Each scheduled email: choose timezone to be considder: contact or owner](https://forum.mautic.org/t/each-scheduled-email-choose-timezone-to-be-considder-contact-or-owner/28474):
>
> My idea is: Each scheduled email (segment or campaign email) has a boolean setting (like a toggle button): sending according to contact timezone (if defined) or sending according to owner timezone. I think these groups of people would benefit from this idea: Sending emails is the basic functionality of Mautic and scheduling to an appropriate time is also - by clarifying the time it will be sent, all user will benefit from this improvement. Why I think they would benefit from this idea: At…

@tobsowo @mikew : Please vote 🙂

---

<div class="post-metadata">

**Author:** ![tobsowo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/tobsowo/32/3096_2.png) [@tobsowo](https://forum.mautic.org/u/tobsowo)\
**Post date:** [June 28, 2023, 11:23pm UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/7 "2023-06-28T23:23:10Z")

</div>

Maybe create a feature request.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)\
**Post date:** [June 30, 2023, 11:23am UTC](https://forum.mautic.org/t/scheduled-emails-timezone-understanding-strange-behaviours/28371/8 "2023-06-30T11:23:11Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
