Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How can we know wheter a mail is sent successfully?

Posted on 2004-11-22
17
Medium Priority
?
270 Views
Last Modified: 2010-04-06
 Consider this:If a user enters a supperfically valid email ,such as rtr2@xr2f.xyz,which is essentially invalid,and the program attempts to send a mail to this address.The result of sending this email will be failure,but how can we know the result?
  I use JMail to send email,and I know the method send of JMail.Message would return False,
which indicates the sending fails.but the value False seems to be the result of some configuration errors(eg. an invalid account which is used to send mail is provided. )
0
Comment
Question by:hengzhe
  • 5
  • 4
  • 2
  • +4
16 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 12651257
Sorry you can't know if the account was an invalid one ...you'll get later an error from the mailserver postmaster of undelivered mail .
The only validation that you could perform is whether the email entered was in the right format. And thats it.
0
 
LVL 18

Expert Comment

by:arantius
ID: 12651278
You could manually connect a socket to port 25 of the appropriate mail server (Yes, you'll have to look up the MX records to find the appropriate server) and issue a VRFY command.
0
 
LVL 1

Author Comment

by:hengzhe
ID: 12651318
  I once activated my account in Yahoo.In the process of activation,an email address was required,but I just entered  henzhe@yahoo.com.cn(in fact,I don't have such an email in Yahoo),and the page prompted that 'please provide a valid email'.
  Does this mean Yahoo could regconize invalid email account?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 33

Expert Comment

by:sajuks
ID: 12651341
Thats cos its searching its own server. If you are the email provider then you've the database where you store all the emails. You can then do a select to check whether the data exists in your d/b and confirm its validity
0
 
LVL 9

Expert Comment

by:jmelika
ID: 12658000
Here is a link to a site with examples on how to do that using different web languages.
http://www.cfdev.com/email/verify/index.cfm

Good luck!
JM
0
 
LVL 1

Expert Comment

by:Yrag1
ID: 12659879
Hi, if u r using asp.net you can validate the domain ie

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Sockets" %>

strIP = DNS.Resolve("yahoo.com").AddressList(0).ToString()
 
theres a bit more code but essentially the DNS.Resolve method will return an IP address if the domain is valid.

If u r not using .net then i dont know.

Gary
0
 
LVL 18

Expert Comment

by:arantius
ID: 12661359
Yrag1:
Yes, but you need to look up the MX records, not the A record.  Especially a domain as big as yahoo, different machines handle the web and the mail.
0
 
LVL 2

Expert Comment

by:alexmay
ID: 12663408
Isn't the best way, the easiest and classic method?
That would be to send the user a mail with a code and require him to read and respond with the code.
If the address was not valid, he would not get the mail.
Otherwise, the code can be used to continue the script.
0
 
LVL 1

Author Comment

by:hengzhe
ID: 12678685
Yes,alexmay,I did it. But I just want to enable the program not to attempt to send out a mail if an invalid receipient address is supplied.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12678725
hengzhe i think that the best that you can do is check whether the email entered is valid or not in the page.There will be cases where the person enters a wrong email address cos he/she just wants to download the stuff and doesnt want to register(receive mail) for anything .Are you trying to prevent such cases ? Then once condition that you could add is send the download link directly to the email id provided. That way you can atleast ensure somewhat that the id provided is a valid one.
Using Jmail or any other mail tool you wont be able to achieve what you want.
0
 
LVL 2

Expert Comment

by:alexmay
ID: 12680393
I don't think you can be really sure of the validity without actually sending the mail and getting the user to read and respond, but...
You could ping the domain mail server to at least see if that gives a reply.
That might reduce the mail send failures a bit.
0
 
LVL 1

Author Comment

by:hengzhe
ID: 12747124
On thing about JMail I am quite sure: send method of JMail.Message would return False if the account which is used to send the mail is wrongly provided(for example,the password is mistyped.).According to this,before sending a mail to a specified receipient(one@mail.com),can we use  the account one@mail.com,though we don't the password,
to log on mail.com,and hence to see whether there is such a user as 'one' on mail.com?If this can be achieved,then validity of the receipient is naturally decided.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12748888
Jmail.Message also fails if the Jmail connection is not proper, internet connection is down ,
syntax error.To log onto jmail.,message you need both username and password as valid.
Just a username wont work as it will still return a false
0
 
LVL 1

Author Comment

by:hengzhe
ID: 12959344
I found the solution:
Set message.logging=true and analyze message.log which is a string reporting the result of an attempt to send an email.
if the sending failed,such string as '1 of 1 servers failed' could be found in message.log.Hence,we could determine whether the email was successfully sent or not.
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12959367
i'd recommend PAQ with points refunded.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12991862
PAQed with points refunded (300)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question