Skip to content

Mail sent twice #248

@Sayelna

Description

@Sayelna

Hello, I use post office with wsgi as cron and the mail is sometimes sent twice as following :

image

My wsgi file :

application = get_wsgi_application()
logger = logging.getLogger(__name__)

# Send queued mails
try:
    import uwsgidecorators
    from django.core.management import call_command

    @uwsgidecorators.timer(10, target='spooler')
    def send_queued_mail(num):
        '''Send queued mail every 10 seconds'''
        call_command('send_queued_mail', processes=1)

    @uwsgidecorators.timer(86400, target='spooler')
    def cleanup_mail(num):
        '''clean mails older than 90 days database every day'''
        call_command('cleanup_mail --days=90', processes=1)

except ImportError:
    logger.error('uwsgidecorators not found. Cron and timers are disabled')

The mail sending :

mail.send(
                owner.user.email,
                settings.DEFAULT_FROM_EMAIL,
                template=template_owner,
                language=translation.get_language(),
                context={
                    'reciever': invitee,
                    'sender': owner,
                    'protocol': 'https',
                    'domain': domain,
                    'project': collaborative,
                },
            )

Any idea of how to fix it ?
Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions