Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
chatBot/send_email.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (28 sloc)
1.96 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib # implements the SMTP protocol to be able to send emails | |
""" sends an email to new users with the details of the account | |
https://www.geeksforgeeks.org/send-mail-gmail-account-using-python/ | |
""" | |
def email(nick, password, mail): | |
try: | |
server = smtplib.SMTP('smtp.gmail.com', 587) #declaration of gmail SMTP server settings | |
server.starttls() #For security, this start the SMTP connection in the Transport Layer Security mode that encrypts all the SMTP commands | |
server.login("theforeignersgroup@gmail.com", "wearethebest101") #information of the account which will send the email | |
msg = "Thank you for joining our CHATBOT!\nDont lose these email.\nYour account details to access our " \ | |
"chatbot:\nLogin Username: " + nick + "\nPassword: " + password | |
server.sendmail("theforeignersgroup@gmail.com", mail, msg) | |
server.quit() #closes the SMTP session | |
except: | |
print("Something went wrong. Probably your wiki connection it is not the best for this service") | |
""" Allows the user to send emails to everyone he wants, using our email""" | |
def create_email(): | |
try: | |
server = smtplib.SMTP('smtp.gmail.com', 587) #declaration of gmail SMTP server settings | |
server.starttls() #For security, this start the SMTP connection in the Transport Layer Security mode that encrypts all the SMTP commands | |
mail = input("Email: ") | |
server.login("theforeignersgroup@gmail.com", "wearethebest101") #information of the account which will send the email | |
msg = input("Message: ") | |
server.sendmail("theforeignersgroup@gmail.com", mail, msg) | |
server.quit() #closes the SMTP session | |
print("Done! What can I help you now?") | |
except: | |
print("Something went wrong. Probably your wifi connection it is not the best for email confirmation or the email is wrong.") |