KilianAlias
KilianAlias

Reputation: 84

SMTPLIB with Python

When I try to send an email, the recipient receives the email fine, but the to address is all messed up. It looks like this: l

This is the code used to send the email:

                            """ % (FROM, ",".join(TO), SUBJECT, TEXT)
                            try:
                                server = smtplib.SMTP("smtp.gmail.com", 587)
                                server.ehlo()
                                server.starttls()
                                server.login(gmail_user, gmail_password)
                                server.sendmail(FROM, TO, message)
                                server.close()
                            except Exception as e:

The message portion of the email is there, but I cannot show it due to privacy reasons. Any help would be greatly appreciated. I really want to fix this bug as it just looks weird. It confuses me though because the email still makes it to the normal inbox despite not having the actual recipients email anywhere.

Upvotes: 0

Views: 48

Answers (1)

Sy Ker
Sy Ker

Reputation: 2180

Well, you are using .join on a string;

% (FROM, ",".join(TO), SUBJECT, TEXT)

Just pass the string;

% (FROM, TO, SUBJECT, TEXT)

Upvotes: 1

Related Questions