Created
June 21, 2020 22:41
-
-
Save shashankvemuri/15b96d85ecb6507f194278f038d9d766 to your computer and use it in GitHub Desktop.
Create the function to send the message
This file contains hidden or 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
| def sendMessage(text): | |
| message = text | |
| email = "" | |
| password = "" | |
| sms_gateway = '' | |
| smtp = "smtp.gmail.com" | |
| port = 587 | |
| server = smtplib.SMTP(smtp,port) | |
| server.starttls() | |
| server.login(email,password) | |
| msg = MIMEMultipart() | |
| msg['From'] = email | |
| msg['To'] = sms_gateway | |
| msg['Subject'] = "Stock Data\n" | |
| body = "{}\n".format(message) | |
| msg.attach(MIMEText(body, 'plain')) | |
| sms = msg.as_string() | |
| server.sendmail(email,sms_gateway,sms) | |
| server.quit() | |
| print ('done') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment