473,396 Members | 2,002 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,396 software developers and data experts.

check pop3 account, return ndr

I need to write a script that will check a catch-all mailbox (pop3) and send
a non delivery report back to the sender of the email.

Background info:
I have a domain hosted on a site that offers unlimited email accounts... the
problem is, emails sent to an invalid address on the domain aren't
automatically returned as non-deliverable. I am, however, able to set up a
catch-all address and able to pick up those emails. Id like to set up a
script that checks that account and generates an appropriate ndr that looks
somewhat like the following:

Your message

To: em***@domain.com
Subject: test non delivery
Sent: Sun, 2 Jan 2005 20:42:39 -0500

did not reach the following recipient(s):

em***@domain.com on Sun, 2 Jan 2005 20:42:39 -0500
The e-mail account does not exist at the organization this message was
sent to. Check the e-mail address, or contact the recipient directly to
find out the correct address.
<server.domain.com #5.1.1>

And if possible, return the original message as an attachment as a normal
non delivery report would.

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they
were a direct result of my fingers and brain not being synchronized or my
lack of caffeine.

Mike Brearley
Nov 19 '05 #1
2 2811
You are going to need a component that will perform the POP3 download and then parse the message. Quiksoft Corporation has the EasyMail Components that will do this for you. Below is a simple sample that will basically do what you want using their components. http://www.quiksoft.com/emdotnet/ You will probably have to change the code a little to get the exact look of failure message you need. You can also create a template for the failure message and have the object import it and replace the tokens.

//create POP3 object
POP3.POP3 pop3Obj = new POP3.POP3();
//Message will be stored in memory
MemoryStream memoryStream = new MemoryStream();

//Connect to the POP3 mail server
pop3Obj.Connect(mailserver);
//Log onto the POP3 mail server
pop3Obj.Login(username,password,POP3.AuthMode.Plai n);

int MessageCount = pop3Obj.GetMessageCount();
int Count;
for(Count=1; Count<MessageCount+; Count++)
{
//Download the first message
pop3Obj.DownloadMessage(Count,memoryStream);
//Set to the start of the stream
memoryStream.Position=0;
//Parse the message
Parse.EmailMessage msgObj = new Parse.EmailMessage(memoryStream);
//Send failure message
string FailureSubject = "Delivery Failure:" + msgObj.Subject;
string FailureFromAddress = "po********@domain.com";
string FailureBody = "To:" + msgObj.To[0].EmailAddress + "\r\nSubject: " + msgObj.Subject + "\r\nSent:" + msgObj.Date.ToString(); //Add adition body or you can just import from a file
SMTP.SMTP.QuickSend("mail.domain.com",msgObj.From[0].EmailAddress,FailureFromAddress,
FailureSubject,FailureBody,SMTP.BodyPartFormat.Pla in);
//Close the memory stream
memoryStream.Close();
memoryStream = new MemoryStream();
//Delete Message
pop3Obj.DeleteMessage(Count);
}
//Disconnect from POP3 server
pop3Obj.Disconnect();

"Mike Brearley" <no****@spam.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
I need to write a script that will check a catch-all mailbox (pop3) and send
a non delivery report back to the sender of the email.

Background info:
I have a domain hosted on a site that offers unlimited email accounts... the
problem is, emails sent to an invalid address on the domain aren't
automatically returned as non-deliverable. I am, however, able to set up a
catch-all address and able to pick up those emails. Id like to set up a
script that checks that account and generates an appropriate ndr that looks
somewhat like the following:

Your message

To: em***@domain.com
Subject: test non delivery
Sent: Sun, 2 Jan 2005 20:42:39 -0500

did not reach the following recipient(s):

em***@domain.com on Sun, 2 Jan 2005 20:42:39 -0500
The e-mail account does not exist at the organization this message was
sent to. Check the e-mail address, or contact the recipient directly to
find out the correct address.
<server.domain.com #5.1.1>

And if possible, return the original message as an attachment as a normal
non delivery report would.

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they
were a direct result of my fingers and brain not being synchronized or my
lack of caffeine.

Mike Brearley

Nov 19 '05 #2
Unfortunately I'm doing this work free of charge for a non-profit organization. Is there anything out there on the open source arena that's free of charge?

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they were a direct result of my fingers and brain not being synchronized or my lack of caffeine.

Mike Brearley

"Bill" <ms****@hotmail.com> wrote in message news:Oo**************@TK2MSFTNGP09.phx.gbl...
You are going to need a component that will perform the POP3 download and then parse the message. Quiksoft Corporation has the EasyMail Components that will do this for you. Below is a simple sample that will basically do what you want using their components. http://www.quiksoft.com/emdotnet/ You will probably have to change the code a little to get the exact look of failure message you need. You can also create a template for the failure message and have the object import it and replace the tokens.

//create POP3 object
POP3.POP3 pop3Obj = new POP3.POP3();
//Message will be stored in memory
MemoryStream memoryStream = new MemoryStream();

//Connect to the POP3 mail server
pop3Obj.Connect(mailserver);
//Log onto the POP3 mail server
pop3Obj.Login(username,password,POP3.AuthMode.Plai n);

int MessageCount = pop3Obj.GetMessageCount();
int Count;
for(Count=1; Count<MessageCount+; Count++)
{
//Download the first message
pop3Obj.DownloadMessage(Count,memoryStream);
//Set to the start of the stream
memoryStream.Position=0;
//Parse the message
Parse.EmailMessage msgObj = new Parse.EmailMessage(memoryStream);
//Send failure message
string FailureSubject = "Delivery Failure:" + msgObj.Subject;
string FailureFromAddress = "po********@domain.com";
string FailureBody = "To:" + msgObj.To[0].EmailAddress + "\r\nSubject: " + msgObj.Subject + "\r\nSent:" + msgObj.Date.ToString(); //Add adition body or you can just import from a file
SMTP.SMTP.QuickSend("mail.domain.com",msgObj.From[0].EmailAddress,FailureFromAddress,
FailureSubject,FailureBody,SMTP.BodyPartFormat.Pla in);
//Close the memory stream
memoryStream.Close();
memoryStream = new MemoryStream();
//Delete Message
pop3Obj.DeleteMessage(Count);
}
//Disconnect from POP3 server
pop3Obj.Disconnect();

"Mike Brearley" <no****@spam.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
I need to write a script that will check a catch-all mailbox (pop3) and send
a non delivery report back to the sender of the email.

Background info:
I have a domain hosted on a site that offers unlimited email accounts... the
problem is, emails sent to an invalid address on the domain aren't
automatically returned as non-deliverable. I am, however, able to set up a
catch-all address and able to pick up those emails. Id like to set up a
script that checks that account and generates an appropriate ndr that looks
somewhat like the following:

Your message

To: em***@domain.com
Subject: test non delivery
Sent: Sun, 2 Jan 2005 20:42:39 -0500

did not reach the following recipient(s):

em***@domain.com on Sun, 2 Jan 2005 20:42:39 -0500
The e-mail account does not exist at the organization this message was
sent to. Check the e-mail address, or contact the recipient directly to
find out the correct address.
<server.domain.com #5.1.1>

And if possible, return the original message as an attachment as a normal
non delivery report would.

--
Posted 'as is'. If there are any spelling and/or grammar mistakes, they
were a direct result of my fingers and brain not being synchronized or my
lack of caffeine.

Mike Brearley

Nov 19 '05 #3

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

Similar topics

2
by: Alexander Franksmann | last post by:
Hello, I'm going to write a anti-spam-program based on a Whitelist. "If the mail sender is found in the database, my program should move the mail into another mailbox" The mailserver fetched the...
4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
2
by: Kevin Beyers | last post by:
Hello Everyone. I am in the process of writing an Internet connection wizard program for the company I am working for. At present, I have all the pieces together beside the part of setting the...
0
by: Hardy Wang | last post by:
Hi, I developed an application to read email from POP3 server. Some of the codes are below: ------------------------------------------------------------------------------- Server = new...
3
by: Craig Buchanan | last post by:
Is there a mechanism to montior a POP3 mailbox, then add the messagesa to a database? If not, I'm assuming that I'd need to build a service that would poll the POP3 account periodically, then...
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
0
by: Daljeet Hanspal | last post by:
hi guys i got this code in c#.net to retrieve mails using pop3 protocal, i'm using MERCURY MAIL SERVER ........ I create a user acccount in mercury by name honey@localhost the problem is ...
2
by: SteveC | last post by:
Hello, I am trying to use POP3_SSL class of the poplib module to read email from my gmail account. I can connect just fine using the example here http://www.python.org/doc/lib/pop3-example.html...
5
by: Craig Buchanan | last post by:
I would like to monitor a POP3 mailbox with multiple clients. However, I want to ensure that each message is processed by only one client. In essence, I would like to treat a POP3 mailbox like a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.