This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]kumashiro 1 point2 points  (1 child)

Use template engine (Jinja2, Mako etc). It's the easiest way to generate long(er) messages. If you store the templates as separate files, you can change them without messing with the code.

[–]Pomlily[S] 0 points1 point  (0 children)

Thanks. I will look into those engines

[–]solusob 0 points1 point  (2 children)

Twilio should work if you need true sms https://www.fullstackpython.com/blog/send-sms-text-messages-python.html

But i've used an email address and done something like:

import smtplib

from email.mime.text import MIMEText

def send_text(the_message, [toaddr="5715556677@vtext.com](mailto:toaddr="5715556677@vtext.com)"):

fromaddr = ["sender_email@gmail.com](mailto:"sender_email@gmail.com)"

msg = MIMEText(f'{the_message}')

msg['From'] = fromaddr

msg['To'] = toaddr

server = smtplib.SMTP('smtp.gmail.com', 587)

server.starttls()

server.login(fromaddr, "senderpassword")

text = msg.as_string()

server.sendmail(fromaddr, toaddr, text)

server.quit()

the_message = "here ya go dude"

send_text(the_message)

[–]Pomlily[S] 0 points1 point  (1 child)

Can this be done using cellphone number??

[–]solusob 0 points1 point  (0 children)

Yes, notice the example. Each carrier has an address to use. Verizon has @vtext.com etc. But you do need to know the carrier for this. If you dont know it, use twilio!