ezgmail icon indicating copy to clipboard operation
ezgmail copied to clipboard

Messages sent using Gmail API marked as suspicious

Open mbonness opened this issue 9 months ago • 2 comments

When I used this in my Python script, the emails received come with a warning "Be careful with this message The sender hasn't authenticated this message so Gmail can't verify that it actually came from them. Avoid clicking links, downloading attachments, or replying with personal information."

This warning is apparently related to setting the message["from"] attribute, commenting out the following line fixes it so messages are sent without the authentication warning:

message["from"] = sender

Screenshot 2023-10-28 at 3 16 08 PM

mbonness avatar Oct 28 '23 20:10 mbonness

I have the same issue!

grinheckerdev avatar Dec 15 '23 10:12 grinheckerdev

I made a small piece of code that patches ezgmail:

import sys
import os

class PatchError(Exception): pass

def patch():
	site_packages = sys.path[4]
	ezgmail_code_path = os.path.join(site_packages, "ezgmail", "__init__.py")
	# __version__ = \"2022.10.10\"
	with open(ezgmail_code_path, "r") as f:
		code = f.read()
	if "__version__ = \"2022.10.10\"" in code:
		pass
	elif "__version__ = \"2022.10.10.PATCHED\"" in code:
		return
	else:
		raise PatchError("Unable to apply patch! Invalid version!")
	lines = code.split("\n")
	lines[6] = "__version__ = \"2022.10.10.PATCHED\""
	lines[491] = "#"+lines[491]
	lines[525] = "#"+lines[525]
	code_new = "\n".join(lines)
	with open(ezgmail_code_path, "w") as f:
		f.truncate()
		f.write(code_new)

Make sure to run patch() before importing ezgmail:

patch()
import ezgmail

grinheckerdev avatar Dec 15 '23 10:12 grinheckerdev