Email in django/python Not Sending -
this question has reply here:
email sending in django code not working 3 answersi trying send direct email message using django. doesn't produce error, message not sending recipient email. there problem codes?
views.py
def contact(request): if request.method == 'post': # if form has been submitted... form = contactform(request.post) # form bound post info if form.is_valid(): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] cc_myself = form.cleaned_data['cc_myself'] recipients = ['canonizadocharm@ymail.com'] if cc_myself: recipients.append(sender) django.core.mail import send_mail send_mail(subject, message, sender, recipients) homecoming httpresponseredirect('/thanks/') # redirect after post else: form = contactform() # unbound form homecoming render(request, 'contact.html', { 'form': form, })
models.py
class contactform(forms.form): subject = forms.charfield(max_length=100) message = forms.charfield() sender = forms.emailfield() cc_myself = forms.booleanfield(required=false)
settings.py
email_backend = 'django.core.mail.backends.filebased.emailbackend' email_file_path = '/tmp/app-messages' # alter proper location # sending mail service email_use_tls = false email_host='localhost' email_port= 25 email_host_user='' email_host_password=''
recipients = ['canonizadocharm@ymail.com',] email_use_tls = true email_host='smtp.gmail.com' email_port=587 email_host_user='your gmail account' email_host_password='your gmail password'
django email
No comments:
Post a Comment