Skip to content

ConnectionResetError: [Errno 54] Connection reset by peer #78

@bhav09

Description

@bhav09

Hey, I have been trying to use the email functionality of knock-knock but I m facing this error. Could you please help me with this?
Sharing the code and error below.

Thanks!
Bhavishya

CODE

imports..

def train_model(X_train,y_train,X_test,y_test):
    classifier=SVC()
    classifier.fit(X_train,y_train)
    return f'Accuracy of the model: {(classifier.score(X_test, y_test))*100}%'

@email_sender(recipient_emails=["bhavishyapandit9@gmail.com"],sender_email="knockknocknotificationstest@gmail.com")
def train_model_email_notify(X_train, y_train, X_test, y_test):
    return train_model(X_train,
                       y_train,
                       X_test,
                       y_test)


wines=datasets.load_wine()
x = wines['data']
y = wines['target']


X_train, X_test, y_train, y_test = train_test_split(x,y,test_size=0.2)
mm = MinMaxScaler()
X_train=mm.fit_transform(X_train)
X_test=mm.fit_transform(X_test)
train_model_email_notify(X_train, y_train, X_test, y_test)

ERROR

Traceback (most recent call last):
  File "/Users/bhavishya.pandit/PycharmProjects/ProjectTesting/test.py", line 30, in <module>
    train_model_email_notify(X_train, y_train, X_test, y_test)
  File "/Library/Python/3.8/site-packages/knockknock/email_sender.py", line 53, in wrapper_sender
    yag_sender.send(current_recipient, 'Training has started 🎬', contents)
  File "/Library/Python/3.8/site-packages/yagmail/sender.py", line 156, in send
    self.login()
  File "/Library/Python/3.8/site-packages/yagmail/sender.py", line 210, in login
    self._login(self.credentials)
  File "/Library/Python/3.8/site-packages/yagmail/sender.py", line 217, in _login
    self.smtp = self.connection(self.host, self.port, **self.kwargs)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/smtplib.py", line 1034, in __init__
    SMTP.__init__(self, host, port, local_hostname, timeout,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/smtplib.py", line 253, in __init__
    (code, msg) = self.connect(host, port)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/smtplib.py", line 339, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/smtplib.py", line 1042, in _get_socket
    new_socket = self.context.wrap_socket(new_socket,
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 54] Connection reset by peer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions