teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

読める場合と読めない場合のスクリーンショットを追加しました。

2019/03/31 12:07

投稿

striker
striker

スコア7

title CHANGED
File without changes
body CHANGED
@@ -46,4 +46,6 @@
46
46
 
47
47
  ### 補足情報(FW/ツールのバージョンなど)
48
48
 
49
+
49
- ここにより詳細な情報を記載してください。
50
+ ![読める場合](dcf3351668fda1d8a0c9f7b4c7b0b0fa.png)
51
+ ![読めない場合](790dc0fea9b8204e3519a58fbe58e394.png)

1

ソースを追記しました。

2019/03/31 12:07

投稿

striker
striker

スコア7

title CHANGED
File without changes
body CHANGED
@@ -17,7 +17,27 @@
17
17
  ### 該当のソースコード
18
18
 
19
19
  ```python
20
+ parent = MIMEMultipart()
21
+ body = MIMEText(text, 'plain', 'utf-8')
22
+ parent.attach(body)
23
+
24
+
25
+ attachment = MIMEBase(type, subtype, encoders='utf-8')
26
+ file = open(path, 'rt', encoding='utf-8')
27
+ attachment.set_payload(file.read())
20
- ソースコード
28
+ file.close()
29
+ encoders.encode_base64(attachment)
30
+ parent.attach(attachment)
31
+ attachment.add_header("Content-Disposition","attachment", filename=filename)
32
+
33
+
34
+ parent['Subject'] = Header(subject, charset)
35
+ parent['From'] = from_address
36
+ parent['To'] = ",".join(to_address)
37
+ parent['Date'] = formatdate(localtime=True)
38
+
39
+ smtp = smtplib.SMTP('xxx.xxx.xxx.xxx', 25)
40
+ smtp.sendmail(from_address, to_address + bcc_addrs, parent.as_string())
21
41
  ```
22
42
 
23
43
  ### 試したこと