Im trying to use the localmail
library in order to create my email server. I created a thread for this with ports for SMTP, IMAP, and HTTP (not relevant now). I succeeded in sending messages to the mail server with SMTP; now I'm trying to fetch the data with IMAP, and while I can connect to the server I cannot select mailbox and search.
import imaplib
import smtplib
import email.utils
import threading
import localmail
from email.mime.text import MIMEText
import socket
def local_mail(name):
print "working with localmail"
thread = threading.Thread(
target=localmail.run,
args=(2025, 2143, 8880, name)
)
thread.start()
print "do_stuff"
#localmail.shutdown_thread(thread)
#print "shutdown localmail"
# main
IPAddr = socket.gethostbyname(socket.gethostname())
IpRecv="not publising my ip"
print("Your Computer IP Address is: " + IPAddr)
# Create the message
msg = MIMEText('This is the body of the message.')
msg['To'] = email.utils.formataddr(('Recipient-', IPAddr))
msg['From'] = email.utils.formataddr(('Author-', IpRecv))
msg['Subject'] = 'Simple test message'
local_mail('localmail.mbox')
server = smtplib.SMTP(IPAddr, 2025)
print "opening connection to smtp server"
server.set_debuglevel(True) # show communication with the server
try:
server.sendmail(IPAddr, IpRecv, msg.as_string())
print "sending email..."
except:
print "no"
finally:
server.quit()
import getpass, imaplib
M = imaplib.IMAP4(IPAddr,2143)
M.state="AUTH"
print "P"
try:
M.select("inbox")
print 1
except Exception,e:
print str(e)
"""
typ, data = M.search(None, 'ALL')
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()
except imaplib.IMAP4.error,err:
print err
"""
I'm getting the error:
SELECT command error: BAD ['Unsupported command']