質問編集履歴
2
読める場合と読めない場合のスクリーンショットを追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -94,4 +94,8 @@
|
|
94
94
|
|
95
95
|
|
96
96
|
|
97
|
+
|
98
|
+
|
97
|
-
|
99
|
+
![読める場合](dcf3351668fda1d8a0c9f7b4c7b0b0fa.png)
|
100
|
+
|
101
|
+
![読めない場合](790dc0fea9b8204e3519a58fbe58e394.png)
|
1
ソースを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,47 @@
|
|
36
36
|
|
37
37
|
```python
|
38
38
|
|
39
|
+
parent = MIMEMultipart()
|
40
|
+
|
41
|
+
body = MIMEText(text, 'plain', 'utf-8')
|
42
|
+
|
43
|
+
parent.attach(body)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
attachment = MIMEBase(type, subtype, encoders='utf-8')
|
50
|
+
|
51
|
+
file = open(path, 'rt', encoding='utf-8')
|
52
|
+
|
53
|
+
attachment.set_payload(file.read())
|
54
|
+
|
39
|
-
|
55
|
+
file.close()
|
56
|
+
|
57
|
+
encoders.encode_base64(attachment)
|
58
|
+
|
59
|
+
parent.attach(attachment)
|
60
|
+
|
61
|
+
attachment.add_header("Content-Disposition","attachment", filename=filename)
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
parent['Subject'] = Header(subject, charset)
|
68
|
+
|
69
|
+
parent['From'] = from_address
|
70
|
+
|
71
|
+
parent['To'] = ",".join(to_address)
|
72
|
+
|
73
|
+
parent['Date'] = formatdate(localtime=True)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
smtp = smtplib.SMTP('xxx.xxx.xxx.xxx', 25)
|
78
|
+
|
79
|
+
smtp.sendmail(from_address, to_address + bcc_addrs, parent.as_string())
|
40
80
|
|
41
81
|
```
|
42
82
|
|