I have written code in python using smtp-lib to send email through my gmail account. The email gets sent, but the email recipient is sent as a BCC. I think that will work, but I want it to look normal and sending one email should not be sent as BCC, since there are not two email addresses.
I've looked at python documentation for smtp-lib and know I need to use the sendmail() attribute, but there does not look to be any options for my BCC problem.
import smtplib
gmail_user = '******@gmail.com'
gmail_password = '*********'
sent_from = gmail_user
to = '*************'
subject = 'TEST TEST TEST'
email_text = 'TEST TEST TEST'
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_password)
server.sendmail(sent_from, to, email_text)
server.quit()
print('email sent')
I want the 'to' address to be sent as a normal email and not to BCC.
You have to put the recipient into the email text:
email_text = """
Subject: {}
From: {}
To: {}
TEST TEST TEST
""".format(subject,sent_from,to)