python - Django sending Email confusion -


i've used 1 application sending email user notification. in application setting.py file contains confusing terms in

setting file

email_use_tls = true 

i'm not sure ,

email_host = 'smtp.gmail.com' email_host_user = 'rquest186@gmail.com' 

what variety in two

and if host declared here

mail.py

def send_mail(title,message,reciver):     try:         mails = 'smtp.gmail.com'         mailp = 587         mailusr = "idefusiontest2015@gmail.com"          mailpass = "********"          # create text/plain message         msg = mimemultipart('alternative')          msg['subject'] = title         msg['from'] = mailusr         msg['to'] = reciver          html="<html><head></head><body><p>"+message.replace("\n","<br>")+"</p></body></html>"          part2 = mimetext(html, 'html')          msg.attach(part2)          # send message via our own smtp server, don't include         s = smtplib.smtp(mails,mailp)         s.ehlo()         s.starttls()         s.ehlo()         s.login(mailusr,mailpass)         s.sendmail(mailusr, [reciver], msg.as_string())         s.quit()      except exception e:         print(e) 

in

 mailusr = "idefusiontest2015@gmail.com" ???? what's ? 

i'm new this. , it's confusing me. in adv.

you need provide gmail account send mail from:

mailusr = "idefusiontest2015@gmail.com"  mailpass = "********" 

mailusr emailid , mailpass passowrd of account.

it sending mail logging gmail account using these emailid , password , sending mail.

so if want send need use emailid , password in place of that.

settings.py

you need have these settings.

email_backend = 'django.core.mail.backends.smtp.emailbackend' email_host = 'smtp.sendgrid.net' email_host_user = 'username' email_host_password = 'password' email_port = 587 email_use_tls = true 
  • email_host smtp service using. in case sendgrid in case gmail.

  • email_host_user username smtp service in case gmailid , email_host_password password account.

i think should clear now.

hope helps!!!


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -