Constructing RFC2822 Message

N

Narendra

Hi All,

This is narendra from india doing my engineering.

i need to develop an E-mail client in python,which connects to my MTA
on port 25 and sends email from there.

I was able to do that but my e-mail is ending in bulk when i'm trying
to senf to hotmail/msn.

here im giving the code of my program.
**********************************************************************************************
import socket,string
import sys
import time
from email import Encoders
import email.Message
import email.Utils
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
# Reading IPConfig File
clientSendingPort = 9000
headuni = '000119-000257-454777-'
headadd = 555650
i = 0
def read(infile):
try:
flopen = open(infile,'r')
flines = flopen.readlines()
flopen.close()
return flines
except IOError:
print sys.exc_info()

if len(sys.argv) != 3:
print 'Usage: IPAuditMain.py <IPConfig File Name> <Email Address
File Name>'
sys.exit()
try:
ipConfigLines = read(sys.argv[1])
emailAddConfigLines = read(sys.argv[2])
print("reading is over")
for line in ipConfigLines:
print("hello")
print line
clIpAddress,injectIPAddress,extnIP,fromadd =
string.split(line,',')
print clIpAddress,injectIPAddress,extnIP
print("how come")

timestamp=time.strftime("[%y%m%d-%H%M%S]",time.localtime(time.time()))
headerUnq = str(headuni) + timestamp
headadd = headadd + 5;
print headerUnq
for recptEmailAdd in emailAddConfigLines:
print("wt happened")
print recptEmailAdd
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "socket created"
soc.bind((clIpAddress,clientSendingPort))
#print soc.recv(9867)
print "after binding"
soc.connect((injectIPAddress, 25)) # SMTP
print recptEmailAdd
i = i +1
clientSendingPort = clientSendingPort + 1
soc.send("mail from:"+fromadd+"\n")
print soc.recv(9869)
soc.send("rcpt to:"+ recptEmailAdd +"\n")
print soc.recv(9869)
soc.send("data\n")
print soc.recv(9869)
print headerUnq
msg = MIMEBase('multipart','alternative')
msg['X-PVIQ'] = headerUnq
msg['Date']=email.Utils.formatdate(localtime=1)
#msg['Return-Path'] = fromadd
msg['Subject'] = 'Our convo zt'+extnIP
msg['From'] = fromadd
msg['To'] = recptEmailAdd
msg.preamble = 'You will not see this in a MIME-aware mail
reader.\n'
msg.epilogue = ''
outer = MIMEText('\nHai Bob '+
'What are you doing?
\n\nRegards,',_subtype='plain')
msg.attach(outer)
print("narendra u got here")
soc.send(msg.as_string(0))
print("u have sent the data ")
soc.send("\n.\n")
print("quit")
print soc.recv(9869)
clientSendingPort = clientSendingPort + 1
soc.close()
except IOError:
print sys.exc_info()
except:
print 'Exception Found. Unable to process'
*******************************************************************************************

Can anyone please help me out how to fix the problem.

Thanks,
Narendra
 
J

jepler

I was able to do that but my e-mail is ending in bulk when i'm trying
to senf to hotmail/msn.

Perhaps this is an over-zealous filter on the hotmail/msn side, not a
problem with Python.

I don't know for sure, but some news stories indicate that without the
presence of a special DNS record, microsoft treats messages as spam--
e.g. http://news.zdnet.com/2100-1009-5758365.html

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDlFI9Jd01MZaTXX0RAhhrAKCdyTqh+3Dd5ldwri/Tl/CVVI5bAACeMIOH
Jtoahfy3PvMJnVcGd1IIGkA=
=AD8o
-----END PGP SIGNATURE-----
 
N

Narendra

Thanks jep for the quick response.But when im sending with different
program written in java i was able to send into inbox.

So i thought problem was with the python code only.

Narendra
 
S

Steve Holden

Narendra said:
Thanks jep for the quick response.But when im sending with different
program written in java i was able to send into inbox.

So i thought problem was with the python code only.

Narendra
Are you sending from a Windows XP client? If so the firewall may be
getting in your way. (It may already trust Java).

You don't report the actual error, so it's difficult to say waht's going
wrong.

regards
Steve
 
N

Narendra

Thanks Steve, No I'm not using windows XP client. I'm using linux
client and no firewall is there

Thanks,
Narendra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top