Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ce2c0a

Browse files
committed
Email snippets
1 parente5cdf17 commit2ce2c0a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

‎Python/Emails/mail-demo.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
importos
3+
importsmtplib
4+
importimghdr
5+
fromemail.messageimportEmailMessage
6+
7+
EMAIL_ADDRESS=os.environ.get('EMAIL_USER')
8+
EMAIL_PASSWORD=os.environ.get('EMAIL_PASS')
9+
10+
contacts= ['YourAddress@gmail.com','test@example.com']
11+
12+
msg=EmailMessage()
13+
msg['Subject']='Check out Bronx as a puppy!'
14+
msg['From']=EMAIL_ADDRESS
15+
msg['To']='YourAddress@gmail.com'
16+
17+
msg.set_content('This is a plain text email')
18+
19+
msg.add_alternative("""\
20+
<!DOCTYPE html>
21+
<html>
22+
<body>
23+
<h1 style="color:SlateGray;">This is an HTML Email!</h1>
24+
</body>
25+
</html>
26+
""",subtype='html')
27+
28+
29+
withsmtplib.SMTP_SSL('smtp.gmail.com',465)assmtp:
30+
smtp.login(EMAIL_ADDRESS,EMAIL_PASSWORD)
31+
smtp.send_message(msg)

‎Python/Emails/simple.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body>
4+
<h1style="color:SlateGray;">This is an HTML Email!</h1>
5+
</body>
6+
</html>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp