def drawtext(text, size, nwords, x, y, fontcolor, print=0, path='arial.ttf'): # --------------------- Making the Resume --------------------- # Wrapping the text draw = ImageDraw.Draw(tmp) font = ImageFont.truetype(path, size) lines = textwrap.wrap(text, nwords) for line in lines: w, h = font.getsize(line) draw.text(xy=(x, y), text=line, fill=fontcolor, font=font) y = y + h + 6 if print: tmp.show() tmp.save('user_resume/Resume_' + str(data["name"].replace(" ", "")) + '.pdf') # Variable Initialization filename = 'user_resume/Resume_' + str(data["name"].replace( " ", "")) + '.pdf' gmail_id = settings.EMAIL_HOST_USER gmail_subject = 'Resume: By Dignizant Jobs' gmail_content = """ Hello <name>, It's wonderful that you chose Our service to make your resume. Good luck for your interview. Regards, Dignizant Jobs """ s = smtplib.SMTP("smtp.gmail.com", 587) s.starttls() # Traffic encryption s.login(settings.EMAIL_HOST_USER, settings.EMAIL_HOST_PASSWORD) msg = EmailMessage() msg['Subject'] = gmail_subject msg['From'] = gmail_id msg['To'] = data['email'] gmail_content = gmail_content.replace("<name>", data['name']) msg.set_content(gmail_content) # Attaching the Poster f = open(filename, 'rb') fdata = f.read() # fname = 'images/' + CertificateFileName fname = 'Resume_' + str(data["name"].replace(" ", "")) + '.pdf' file_type = imghdr.what(f.name) msg.add_attachment(fdata, maintype='application', subtype='octet-stream', filename=fname) s.send_message(msg) s.quit() return x, y