Connection refused when sending email using Scrapy mail module - python

I am trying to send email after scraping using Scrapy, but I get this error:
2017-02-25 12:44:44 [scrapy.mail] ERROR: Unable to send mail: To=['<my_email>#gmail.com'] Cc=['<my_email>#gmail.com'] Subject="Test" Attachs=0- Connection was refused by other side: 10061: No connection could be made because the target machine actively refused it..
This is the code:
mailer = scrapy.mail.MailSender.from_settings(scrapy.conf.settings)
mailer.send(to=["<my_email>#gmail.com"], subject="Test",
body="Test", cc=["<my_email>#gmail.com"])
How can I send email successfully using Scrapy MailSender()

To send email you need an SMTP server that allows you to send email, and to configure the connection to that SMTP server through mail settings like MAIL_HOST and MAIL_PORT.
If you search the internet for the name of your email provider (e.g. Kolab Now, Google Mail) and "SMTP", you should be able to find the settings you need to use.

Related

Getting errors connecting to mail servers using SMTP in python

I want to send a mail using smtplib in python. I tried to connect to the gmail server and protonmail server.But getting these errors,
When trying to connect to Gmail server,
import smtplib
server=smtplib.SMTP('smtp.gmail.com',465)
Error: "A connection attempt failed because the connected party did not properly respond after a period of time"
When trying to connect to protonmail server,
import smtplib
Server=smtplib.SMTP('127.0.0.1',1025)
Error: "No connection could be made because the target machine actively refused it."
Please let me know how can I resolve it.
Try this for email,
import smtplib
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("yourmail#gmail.com", "yourpassword")

Why python post request with nordvpn socks proxy doesn't work on distant hosted server while working on local windows?

On a python app, i send a request post through a socks proxy of nordvpn :
(los-angeles.us.socks.nordhold.net)
prox = {'https':'socks5://user:pass#host:port'}
requests.post(url, proxies=prox, data=data)
While this code works on my local windows environnement, the request been sent and received, the code gets an error when the app is hosted on a shared server.
socks.ProxyConnectionError: Error connecting to SOCKS5 proxy los-angeles.us.socks.nordhold.net:1080:
[Errno 111] Connection refused
Hoster says i need a root ssh access from a dedidated server. But how would it help ?
amsterdam.nl.socks.nordhold.net
atlanta.us.socks.nordhold.net
dallas.us.socks.nordhold.net
dublin.ie.socks.nordhold.net
ie.socks.nordhold.net
los-angeles.us.socks.nordhold.net
nl.socks.nordhold.net
se.socks.nordhold.net
stockholm.se.socks.nordhold.net
us.socks.nordhold.net
Port is 1080
your username is manually setup credentials and passwords too.
Dont try to use ur login data for it because it will never work.
Try with closing the connection.

Cannot list FTP directory using ftplib – but FTP client works

I'm trying to connect to an FTP but I am unable to run any commands.
ftp_server = ip
ftp_username = username
ftp_password = password
ftp = ftplib.FTP(ftp_server)
ftp.login(ftp_username, ftp_password)
'230 Logged on'
ftp.nlst()
The ftp.nlst throws this error:
Error:
[WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
I've tested the connection using FileZilla (running on the same machine) and it works fine.
This is FileZilla log:
Status: Connection established, waiting for welcome message...
Status: Insecure server, it does not support FTP over TLS.
Status: Logged in Status: Retrieving directory listing...
Status: Server sent passive reply with unroutable address. Using server address instead.
Status: Directory listing of "/" successful
Status: Server sent passive reply with unroutable address
The above means that the FTP server is misconfigured. It sends its internal network IP to outside network (to the client – FileZilla or Python ftplib), where it is invalid. FileZilla can detect that and automatically fall back to the original IP address of the server.
Python ftplib does not do this kind of detection.
You need to fix your FTP server to return the correct IP address.
If it is not feasible to fix the server (it's not yours and the admin is not cooperative), you can make ftplib ignore the returned (invalid) IP address and use the original address instead by overriding FTP.makepasv:
class SmartFTP(FTP):
def makepasv(self):
invalidhost, port = super(SmartFTP, self).makepasv()
return self.host, port
ftp = SmartFTP(ftp_server)
# the rest of the code is the same
In recent versions of Python (3.6 and newer), ftplib doesn't consider the IP address in PASV response on its own.
Another solution may be to use IPv6. See Python 3.8.5 FTPS connection.
For a different problem with similar consequences, see vsftpd returns 0,0,0,0 in response to PASV.

How i can send automatic email when i confirm a form request on Odoo 8?

i'm a new Odoo developer and i need to send automatic email when i confirm a form request, and i can input manually sender and receiver the email.
Any one have a sample, tutorial or anyone can help me, i dont know the steps or configure of mail server because i use localhost, Thank you
Go to setting-> Technical setting-> Email-> Outgoing Mail Servers
Set SMTP server, SMTP port other credentials
eg:
SMTP Server: smtp.gmail.com
SMTP port: 587
connection security: TLS(STARTTLS)
Once done, Test the connection is setup properly or not by clicking Test connection button.
You can send mail by calling send_mail()

How to access IMAP server through a proxy server

i am trying to get all inbox emails from an emails in yahoo, cause of many emails in a day ,yahoo refuse my connections for a while , i want to connect via proxy when yahoo refuses my actual ip and gives that erro :
Cannot connect to : Can not authenticate to IMAP server: [CLOSED] IMAP connection broken (authenticate).
is there a way to connect to yahoo IMAP over proxy ?
i tried this way but no luck :
import socks
import socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS4,proxy_ip,port,True)
socket.socket = socks.socksocket
M = imaplib.IMAP4_SSL("imap.mail.yahoo.com")
a = M.login(user, passwd)

Categories

Resources