gmail-api-client 0.1.0__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/PKG-INFO +1 -1
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/pyproject.toml +1 -1
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client/client.py +22 -3
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/PKG-INFO +1 -1
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/tests/test_client.py +15 -1
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/README.md +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/setup.cfg +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client/__init__.py +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client/exceptions.py +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/SOURCES.txt +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/dependency_links.txt +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/requires.txt +0 -0
- {gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
import os
|
|
3
3
|
from email.message import EmailMessage
|
|
4
|
+
from email import policy
|
|
5
|
+
from html import escape
|
|
4
6
|
from typing import Optional
|
|
5
7
|
|
|
6
8
|
from google.auth.transport.requests import Request
|
|
@@ -81,9 +83,9 @@ class GmailClient:
|
|
|
81
83
|
) -> EmailMessage:
|
|
82
84
|
"""Create an email message."""
|
|
83
85
|
|
|
84
|
-
message = EmailMessage(
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
message = EmailMessage(
|
|
87
|
+
policy=policy.SMTP
|
|
88
|
+
)
|
|
87
89
|
|
|
88
90
|
if sender:
|
|
89
91
|
message["From"] = sender
|
|
@@ -91,6 +93,23 @@ class GmailClient:
|
|
|
91
93
|
message["To"] = to
|
|
92
94
|
message["Subject"] = subject
|
|
93
95
|
|
|
96
|
+
# Plain-text fallback
|
|
97
|
+
message.set_content(body)
|
|
98
|
+
|
|
99
|
+
# HTML version
|
|
100
|
+
html_body = f"""
|
|
101
|
+
<html>
|
|
102
|
+
<body>
|
|
103
|
+
<p>{escape(body)}</p>
|
|
104
|
+
</body>
|
|
105
|
+
</html>
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
message.add_alternative(
|
|
109
|
+
html_body,
|
|
110
|
+
subtype="html",
|
|
111
|
+
)
|
|
112
|
+
|
|
94
113
|
return message
|
|
95
114
|
|
|
96
115
|
@staticmethod
|
|
@@ -34,7 +34,21 @@ def test_create_message():
|
|
|
34
34
|
|
|
35
35
|
assert message["To"] == "recipient@example.com"
|
|
36
36
|
assert message["Subject"] == "Test Subject"
|
|
37
|
-
|
|
37
|
+
|
|
38
|
+
assert message.get_content_type() == "multipart/alternative"
|
|
39
|
+
|
|
40
|
+
parts = message.get_payload()
|
|
41
|
+
|
|
42
|
+
assert len(parts) == 2
|
|
43
|
+
|
|
44
|
+
plain_part = parts[0]
|
|
45
|
+
html_part = parts[1]
|
|
46
|
+
|
|
47
|
+
assert plain_part.get_content_type() == "text/plain"
|
|
48
|
+
assert html_part.get_content_type() == "text/html"
|
|
49
|
+
|
|
50
|
+
assert plain_part.get_content().strip() == "Test Body"
|
|
51
|
+
assert "Test Body" in html_part.get_content()
|
|
38
52
|
|
|
39
53
|
|
|
40
54
|
def test_create_message_with_sender():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/requires.txt
RENAMED
|
File without changes
|
{gmail_api_client-0.1.0 → gmail_api_client-0.1.3}/src/gmail_api_client.egg-info/top_level.txt
RENAMED
|
File without changes
|