Cannot send mail with Amazon SES in background job

I have configured Amazon SES to send mails from the system, using boto3. The credentials are stored in site_config.json. Whenever I try to put this function into a background job (be it long or default), it doesn’t send mail. An error is logged saying: ValueError(‘Invalid endpoint: https://email…amazonaws.com’)
Though when I directly call this function, without enqueue, the function executes correctly and an email is sent.
What could be the reason? I need this solution to optimize the website’s performance.