yagmail icon indicating copy to clipboard operation
yagmail copied to clipboard

Proxy support

Open b3mb4m opened this issue 9 years ago • 9 comments

ps : socks project is clearly not working and outdated,

b3mb4m avatar Sep 09 '16 02:09 b3mb4m

I don't understand the relation to yagmail?

kootenpv avatar Sep 09 '16 07:09 kootenpv

Just anohter mail related feature to add, nothing special

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

b3mb4m avatar Sep 09 '16 14:09 b3mb4m

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 avatar Nov 01 '16 18:11 kootenpv

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.

xk7612 avatar Jul 11 '18 15:07 xk7612

@xk7612 I have no idea to be honest.

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

kootenpv avatar Jul 11 '18 15:07 kootenpv

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

chenerg avatar Nov 19 '18 02:11 chenerg

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

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

kootenpv avatar Apr 23 '19 21:04 kootenpv

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

mesondzh avatar Sep 17 '19 11:09 mesondzh

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

kootenpv avatar Sep 17 '19 11:09 kootenpv