Cog-Creators / Cog-Board

Redirect: https://cogboard.red
12 stars 3 forks source link

Email Sender #79

Open Jan200101 opened 7 years ago

Jan200101 commented 7 years ago

You get the idea

Kowlin commented 7 years ago

No. I don't...

calebj commented 7 years ago

Sending mail with Python is pretty simple thanks to the email tools included in the standard library. It can be dropped into any cog, if you're looking to add this functionality to an existing one.

If you're running on a UNIX system that has sendmail, you can use that without an SMTP server (credit):

from email.mime.text import MIMEText
from subprocess import Popen, PIPE

msg = MIMEText("Here is the body of my message")
msg["From"] = "me@example.com"
msg["To"] = "you@example.com"
msg["Subject"] = "This is the subject."
p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE, universal_newlines=True)
p.communicate(msg.as_string())

Otherwise, you will need to spin up your own SMTP server or use one for which you have an account, then write code using smtplib from the standard library to send mail with it. Or you can use a service such as SendGrid , MailChimp or Mailgun, all of which have free tiers and Python APIs.

This is all I can answer without more specifics. Please update this issue with "a detailed description of your idea preferably with examples of how you are thinking it should be used" as outlined in this repository's contributing guidelines. We're not mind readers.