invoice_html = html2pdf('product/invoice.html', context)

                subject = 'Invoice for your order'
                message = 'Please find attached the invoice for your order. 
This is a no reply mail but you can contact us through 
[email protected] for any enquiry.'
                from_email = settings.EMAIL_HOST_USER
                to_email = order.email

                # Convert invoice_html to a File object
                invoice_file = BytesIO(invoice_html)

                email = EmailMessage(subject, message, from_email, [to_email
])
                email.attach(
                    'invoice.pdf', invoice_file.getvalue(), 
'application/pdf')
                email.send()

                subject_ = 'Notice for an order'
                message_ = f'Please find notice information for { order.
full_name } new order.'
                from_email_ = settings.EMAIL_HOST_USER
                to_email_ = '[email protected]'

                notice = EmailMessage(subject_, message_,
                                      from_email_, [to_email_])
                notice.attach(
                    'invoice.pdf', invoice_file.getvalue(), 
'application/pdf')
                notice.send()

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = os.getenv('EMAIL_HOST') #mail.privateemail.com
EMAIL_PORT = os.getenv('EMAIL_PORT') #465
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
I tried sending mail to from my privateemail i got from namecheap to gmail 
but it gives thr content below: This is the mail system at host 
mailout-pe-b.jellyfish.systems.

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d77e903b-b210-43b0-9315-49abf082c60bn%40googlegroups.com.

Reply via email to