質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
|
7
7
|
**Exception Type: UnicodeEncodeError
|
8
8
|
Exception Value:
|
9
|
-
'ascii' codec can't encode character '\u3042' in position 32: ordinal not in range(128)
|
9
|
+
'ascii' codec can't encode character '\u3042' in position 32: ordinal not in range(128)
|
10
|
+
Exception Location: /usr/local/anaconda3/lib/python3.9/subprocess.py, line 1754, in _execute_child**
|
10
11
|
|
11
12
|
コードは以下になります。
|
12
13
|
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -48,3 +48,19 @@
|
|
48
48
|
サーバーの文字コードはUTF-8になっています。
|
49
49
|
**# echo $LANG
|
50
50
|
ja_JP.UTF-8**
|
51
|
+
|
52
|
+
▽追記
|
53
|
+
対話型モードで実行したところ、エラーが出力されませんでした。
|
54
|
+
```ここに言語を入力
|
55
|
+
# python3
|
56
|
+
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
|
57
|
+
[GCC 7.5.0] :: Anaconda, Inc. on linux
|
58
|
+
Type "help", "copyright", "credits" or "license" for more information.
|
59
|
+
>>> import subprocess
|
60
|
+
>>> subject = 'あ'
|
61
|
+
>>> message = 'test'
|
62
|
+
>>> cmd = "echo -e '" + message + "' | mail -s '" + subject + "' test@test.com"
|
63
|
+
>>> subprocess.run(cmd, shell=True, encoding="utf8", universal_newlines=True)
|
64
|
+
CompletedProcess(args="echo -e 'test' | mail -s 'あ' test@test.com", returncode=0)
|
65
|
+
```
|
66
|
+
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,3 +42,9 @@
|
|
42
42
|
以下のコマンドでサーバーから日本語メールを送れるので、Pythonの方の問題だと思っています。
|
43
43
|
|
44
44
|
**echo -e 'This is a test mail.' | mail -s 'あ' test@test.com**
|
45
|
+
|
46
|
+
|
47
|
+
▽追記
|
48
|
+
サーバーの文字コードはUTF-8になっています。
|
49
|
+
**# echo $LANG
|
50
|
+
ja_JP.UTF-8**
|