email - Why SMTP sendmail works fast in local but very slow in my dev server Django 1.6 -
email - Why SMTP sendmail works fast in local but very slow in my dev server Django 1.6 -
i using smtp sendmail in project , tried send mail service using smtp sendmail. works fine , sends mail service in 3-4 seconds. same code takes around 5 minutes in dev server. can please help me.
in view function
def send_email(subject, message, recipients, contenttype, attachments = []): try: from_email = "gauravnagpal2002@gmail.com" msg = mimemultipart() msg['subject'] = subject msg['from'] = from_email msg['to'] = ",".join(recipients) msg.attach( mimetext(message) ) f in attachments: part = mimebase('application', "octet-stream") part.set_payload( open(f,"rb").read() ) encoders.encode_base64(part) part.add_header('content-disposition', 'attachment; filename="%s"' % os.path.basename(f)) msg.attach(part) server = smtplib.smtp('localhost') server.sendmail(from_email, recipients, msg.as_string()) server.quit() except exception, e: logger.error(str(e)) can 1 helps me figure out whats doing wrong?
why don't utilize django inbuilt email,
edit settings.py code below:
email_use_tls = true email_host = 'smtp.gmail.com' email_host_user = 'youremail@gmail.com' email_host_password = 'yourpassword' email_port = 587 run interactive mode, python manage.py shell import emailmessage module,
from django.core.mail import emailmessage # send email, email = emailmessage('subject', 'body', t=['mickeyckm@mangooranges.com']) email.save() django email python-2.7 sendmail
Comments
Post a Comment