Hello there, I’m facing an issue with sending emails to an Outlook email, when I attach a pdf file in the email, but It works fine with Gmail accounts, here is my mailgun config in the settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.eu.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@smartovate.com'
EMAIL_HOST_PASSWORD = '9a5c5bb9f50b8d***********'
DEFAULT_FROM_EMAIL = 'postmaster@smartovate.com'
MAILGUN_DOMAIN = 'smartovate.com'
MAILGUN_API_KEY = 'pubkey-572f48****'
And I’m using the EmailMessage
class for this
email = EmailMessage(
subject='Invoice PDF',
body=message,
from_email=settings.DEFAULT_FROM_EMAIL,
to=["finance@smartovate.com",
"work_email@caustaza.com",
"personel_email@gmail.com"
]
)
# ok the issue is here, when I attach a file (In my case pdf) the email is not being sent to outlook, but it works fine with gmail
email.attach(f'invoice_{invoice_id}.pdf', buffer.getvalue(), 'application/pdf')
If anyone has faced this issue before and he manages to solve it, please inform us
Thank you