עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

קליינט SMTP ב Python

Featured Replies

פורסם

התחלתי לכתוב קליינט פשוט ל STMP ב python, אבל מהר מאוד נתקלתי בבעיה.

from socket import *
from string import *
import os

s = socket(AF_INET, SOCK_STREAM)
server = "out.bezeqint.net"
port = 25
try:
s.connect((server, port))
except:
print "connection failed!"
exit(1)


data = s.recv(1000)
code = split(data, " ", 1)[0]
ok = code == "220"
if not ok :
print "error connecting to server"
exit(1)

compname = os.environ['COMPUTERNAME']

s.sendall("HELO " + compname)
data = s.recv(1000)
code = split(data, " ", 1)[0]
ok = code == "250"
if not ok :
print "error saying HELO to server"
s.close()
exit(1)

s.close()

הבעיה היא שהתוכנית נתקעת ב data = s.recv(1000 השני, שאחרי s.sendall("HELO " + compname.

ההשערה שלי היא ש sendall משום מה לא שולח את ההודעה לשרת, והקליינט שלי מחכה לתשובה שהשרת לא שולח בכלל.

לפני שהתחלתי לכתוב שלחתי בעזרת telnet אימייל בצורה הזו והצלחתי.

מישהו יכול לומר מהי הבעיה?

פורסם

שרת ה-SMTP מזהה את סוף החבילה לפי ירידת שורה ("\n")

לכן, תחליף את:


s.sendall("HELO " + compname)

ב:


s.sendall("HELO " + compname + "\n")

פורסם
  • מחבר

אההה, נכון, איך שכחתי..

תודה רבה על העזרה :)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.