Sorry for the poor title, I'm currently experiencing a weird problem with my code. When I send an email using my app, some words has weird spacing in between them.
For example: "Feel free to use our stor age for xx days"
The spacing usually happens on different words depending on the recipients name. I'm guessing the length of the name of the recipient has a factor in this as the email begins with a greeting (e.g Hi John Doe,)
The one I just built is using smptlib library from Python and I'm currently storing the templates in MySQL.
Python code basically looks like this:
server = smtplib.SMTP(mailServer)
msgContent = rawHTMLFromDb.replace('{fullname}', name)
message = MIMEText(msgContent, 'html')
message['From'] = sendFrom
message['To'] = sendTo
message['Subject'] = subject
msg_full = message.as_string()
server.sendmail(sendFrom, sendTo, msg_full)
I'm not sure if there's any bearing but I'm pulling the templates from MySQL that's stored in a LONGTEXT
datatype column.
I also already did a print right after the substitution and confirmed that substitution and weird spacing is not present. It's just viewable on the mail client.
Edit: Some more details on the msgContent
It looks like this:
<!DOCTYPE html><html><head><style>..longCSS</style></head><body><p>Hi {fullname}</p><table>Several other content here.</table></body></html>