when sent the mail it shows an error like,AttributeError: 'int' object has no attribute 'splitlines',can slove this issue
views.py
from django.conf import settings
from django.core.mail import send_mail
from random import randint
def send_emails(request,email):
n = 8
range_start = 10**(n-1)
range_end = (10**n)-1
passgenarate = randint(range_start, range_end)
print passgenarate
password = make_password(passgenarate)
print password
updatepassword = User.objects.filter(email=email).update(password=password)
subject = 'newpassword'
from_email = settings.EMAIL_HOST_USER
recipient_list = email
message = passgenarate
send_mail(subject, message,from_email,[recipient_list],
fail_silently=False, auth_user=None, auth_password=None,
connection=None, html_message=None)
Maybe message = passgenarate
needs to be a str
and it's an int
. Try message = str(passgenarate)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.