473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Constructing RFC2822 Message

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

Dec 5 '05 #1
4 1391
On Mon, Dec 05, 2005 at 06:27:44AM -0800, Narendra wrote:
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-----

Dec 5 '05 #2
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

Dec 5 '05 #3
Narendra wrote:
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
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 5 '05 #4
Thanks Steve, No I'm not using windows XP client. I'm using linux
client and no firewall is there

Thanks,
Narendra

Dec 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Krasimir_Slaveykov | last post by:
Hello , I have a problem with constructing correct SQL. I have tables: TABLE1 wich have FIELD1 and FIELD2 TABLE2 wich have FIELD1 and FIELD2 TABLE3 wich have FIELD1, FIELD2 and FIELD3 I...
3
by: karthick | last post by:
Hi, I am constructing a Message (Body) for sending our Emails. It is around 3000 characters long. But for whatever reason, the last line seems to be broken with a "!" exclamatory mark in it,...
1
by: cainlevy | last post by:
Hey all, What are the pros and cons of defining methods in the constructor vs through the prototype? For example: Constructing: ------------- function MyObj() { this.MyMethod = function()...
19
by: Michael Schuerig | last post by:
In my experience most available books and web publication on CSS are related to web page/site design. Little attention is payed to the design and construction of web-based application for data...
5
by: grocery_stocker | last post by:
Why would someone go through the trouble of constructing an error handling function using variable-length argument lists? Why not just use something like printf()?
1
by: Gravy | last post by:
Hi, When I create a new reference to a webservice proxy class (one that was created when I imported a web reference) there is a slight delay. Can someone tell me what it's doing to cause this...
2
by: richard | last post by:
I'm just dealing with a Roundup bug report in which it's pointed out that time.strftime() doesn't produce RFC2822-compliant date strings when in a locale other than "C". My reading of the RFC...
6
by: Big George | last post by:
Hello, I develop in ASP.NET with VB.NET code. I need some help constructing a class: Worker. I'm designing the properties of this class. The class is filled reading tables in database. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.