Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending attachment fails #228

Open
uklop opened this issue Apr 5, 2022 · 3 comments
Open

Sending attachment fails #228

uklop opened this issue Apr 5, 2022 · 3 comments

Comments

@uklop
Copy link

uklop commented Apr 5, 2022

Thanks for making yagmail.
I'm running yagmail-0.15.277 on python 3.10.

I can't seem to attach a file to my email.
The email arrives just fine but without attachment.

In the code, shown below, I'm sending it to my protonmail account, also when I try to send to a gmail it also fails.

here's the code:

import yagmail
import os

textattach = os.path.join(os.getcwd(), 'test.txt')
print(textattach)

yag = yagmail.SMTP(user='MyEmail@gmail.com', password='hunter2')
#sending the email
yag.send(to='MyOtherEmail@protonmail.com', 
	subject='The subject is bla bla bla', 
	contents='Please find the text file attached', 
	attachments=textattach)

print("Email was sent")

The output is as follows:

C:\Users\RegularUsername\Documents\Scripts\email\test.txt
Email was sent

When opening the path (C:\Users\RegularUsername\Documents\Scripts\email\test.txt) it shows the txt file.

@uklop
Copy link
Author

uklop commented Apr 6, 2022

After some more troubleshooting I found the problem was with protonmail.
In gmail the attached file shows up, no problem.
In protonmail the attached file doesn't show up.

@kootenpv
Copy link
Owner

kootenpv commented Apr 6, 2022

cool, thanks for finding that out

if someone wants to dig into this we could maybe find a way that supports both gmail and protonmail

@uklop
Copy link
Author

uklop commented Apr 6, 2022

Interestingly there's some other stuff I found.
If I send it to my gmail, using the script, there's no issue.
If I forward that email from my gmail to protonmail, there's no issue.

I've also got automatic forwarding set up from my gmail to protonmail.
The email that was automatically forwarded from gmail to protonmail doesn't show the attachment.
If I forward the email from my own gmail to my own gmail, thus triggering the autoforward. There's no issue.

The issue seems to be specifically when sending an email from python using yagmail to protonmail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants