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

Proxy support #51

Open
b3mb4m opened this issue Sep 9, 2016 · 9 comments
Open

Proxy support #51

b3mb4m opened this issue Sep 9, 2016 · 9 comments

Comments

@b3mb4m
Copy link

b3mb4m commented Sep 9, 2016

ps : socks project is clearly not working and outdated,

@kootenpv
Copy link
Owner

kootenpv commented Sep 9, 2016

I don't understand the relation to yagmail?

@b3mb4m
Copy link
Author

b3mb4m commented Sep 9, 2016

Just anohter mail related feature to add, nothing special

yag = yagmail.SMTP('mygmailusername', 'mygmailpassword', 'myproxy)

@kootenpv
Copy link
Owner

kootenpv commented Nov 1, 2016

Oh I have overseen this last message. Could you perhaps give an example for a proxy, I think it would be interesting way. Would we we need an extra library for this functionality?

I found this online:

import smtplib
import socks

#socks.setdefaultproxy(TYPE, ADDR, PORT)
socks.setdefaultproxy(socks.SOCKS5, 'proxy.proxy.com', 8080)
socks.wrapmodule(smtplib)  # in our case yagmail

<continue with yagmail like usual>

Is something like how you had it in mind?

@xk7612
Copy link

xk7612 commented Jul 11, 2018

I tried to send email with socks5 proxy, here is the code:
socks.setdefaultproxy(socks.SOCKS5, 'proxy.proxy.com', 1080)
socks.wrapmodule(yagmail)

Got AttributeError: module 'yagmail' has no attribute 'socket', how to fix this issue? @kootenpv
Thank you.

@kootenpv
Copy link
Owner

@xk7612 I have no idea to be honest.

Maybe you could try socks.wrapmodule(yagmail.smtplib)?

@chenerg
Copy link

chenerg commented Nov 19, 2018

Oh I have overseen this last message. Could you perhaps give an example for a proxy, I think it would be interesting way. Would we we need an extra library for this functionality?

I found this online:

import smtplib
import socks

#socks.setdefaultproxy(TYPE, ADDR, PORT)
socks.setdefaultproxy(socks.SOCKS5, 'proxy.proxy.com', 8080)
socks.wrapmodule(smtplib)  # in our case yagmail

<continue with yagmail like usual>

Is something like how you had it in mind?

this is great

@kootenpv
Copy link
Owner

kootenpv commented Apr 23, 2019

@chenerg Did this code snippet work for you? Then indeed maybe we can add it like this:

yagmail.SMTP(..., proxy="myproxy.proxy.com:8080")

@mesondzh
Copy link

Oh I have overseen this last message. Could you perhaps give an example for a proxy, I think it would be interesting way. Would we we need an extra library for this functionality?

I found this online:

import smtplib
import socks

#socks.setdefaultproxy(TYPE, ADDR, PORT)
socks.setdefaultproxy(socks.SOCKS5, 'proxy.proxy.com', 8080)
socks.wrapmodule(smtplib)  # in our case yagmail

<continue with yagmail like usual>

Is something like how you had it in mind?

@kootenpv thank you, I try to rewrite yagmail.SMTP, it works!
yagmail_proxy_example

@kootenpv
Copy link
Owner

@ds19991999 So we could add the keyword argument proxy to yagmail.SMTP and in the init run the set_proxy method if proxy is not None? If you want you can make a PR and I'd accept it!

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

5 participants