kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

Proxy support #51

Open b3mb4m opened 8 years ago

b3mb4m commented 8 years ago

ps : socks project is clearly not working and outdated,

kootenpv commented 8 years ago

I don't understand the relation to yagmail?

b3mb4m commented 8 years ago

Just anohter mail related feature to add, nothing special

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

kootenpv commented 8 years ago

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 commented 6 years ago

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 commented 6 years ago

@xk7612 I have no idea to be honest.

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

chenerg commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

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 commented 5 years ago

@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!