-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from midoks/dev
0.13.5
- Loading branch information
Showing
9 changed files
with
329 additions
and
31 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# coding: utf-8 | ||
|
||
import smtplib | ||
|
||
from email import encoders | ||
from email.header import Header | ||
from email.mime.text import MIMEText | ||
from email.utils import parseaddr, formataddr | ||
|
||
|
||
def _format_addr(s): | ||
name, addr = parseaddr(s) | ||
return formataddr((Header(name, 'utf-8').encode(), addr)) | ||
|
||
|
||
def send(smtp_host, smtp_port, username, password, to_mail, subject, content): | ||
|
||
smtp = smtplib.SMTP() | ||
smtp.connect(smtp_host, port=smtp_port) | ||
smtp.login(user=username, password=password) | ||
|
||
msg = MIMEText(content, 'plain', 'utf-8') | ||
msg['From'] = _format_addr(username) | ||
msg['To'] = _format_addr(to_mail) | ||
msg['Subject'] = Header(subject, 'utf-8').encode() | ||
|
||
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string()) | ||
return True | ||
|
||
|
||
def sendSSL(smtp_host, smtp_port, username, password, to_mail, subject, content): | ||
|
||
smtp = smtplib.SMTP_SSL(smtp_host, port=smtp_port) | ||
smtp.login(user=username, password=password) | ||
|
||
msg = MIMEText(content, 'plain', 'utf-8') | ||
msg['From'] = _format_addr(username) | ||
msg['To'] = _format_addr(to_mail) | ||
msg['Subject'] = Header(subject, 'utf-8').encode() | ||
|
||
smtp.sendmail(from_addr=username, to_addrs=to_mail, msg=msg.as_string()) | ||
smtp.quit() | ||
return True |
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
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
Oops, something went wrong.