Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 11th, 2007, 03:21 PM
Friend of Wrox
Points: 2,876, Level: 22
Points: 2,876, Level: 22 Points: 2,876, Level: 22 Points: 2,876, Level: 22
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
Default SMTP Email Error Handling

In need to verify whether email addresses passed to an SMTP component in a eweb page are valid. This Try/Catch does NOT return an error if the email address is invalid:

Try
  Dim smtp As New SmtpClient(ConfigurationManager.AppSettings("SMTPS erverName"))

  smtp.Send(mail)
Catch
  m_strErrorMessage = String.Concat("Unable to send email: ", Err.Description)
End Try

...and because it is being sent by the server, the user sending the email never knows it was not delivered. Is there some way to either verify the email addresses entered or catch undeliverable email?
  #2 (permalink)  
Old July 12th, 2007, 08:32 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The mail server won't know that its undeliverable until it tries to send it. "Sending" a message from .NET doesn't really actually send the message. All it does it hand it off to the SMTP server for sending.

An SMTP server can only verify that a email address is bad if that SMTP server is responsible for handling addresses to the email address host. Example:

You have a mail server mail.somedomain.com which handles messages to any email @somedomain.com. If you connect to that mail server and try "emailaddressthatdoesntexist@somedomain.com" that server can deny that mail because it knows that the mail account "emailaddressthatdoesntexist" does indeed not exist. However, if you send mail to "emailaddressthatdoesntexist@someotherdomain.c om", your mail server won't know whether it's good or bad until it tries to connect to "someotherdomain.com"'s mail server to relay the message. By then, your Send call has completed. In fact, it could be days before the message goes thru as the mail server tries to relay the message depending on lots of factors.

If you are sending the mail FROM a monitored account, then the sending mail server should return a bounce message if it doesn't succeed.

-Peter


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem sending email with SMTP in VB.Net Compiler Forum and Wrox.com Feedback 3 November 30th, 2007 07:25 PM
sending email with SMTP authentication (port 26) crmpicco PHP How-To 3 November 4th, 2007 01:18 PM
Sending EMail thru SMTP server in C# - Most of the peri C# 1 December 20th, 2004 09:33 PM
mail() is not sending email on localhost SMTP anshul PHP How-To 5 August 4th, 2004 06:45 AM
Smtp blocked, how can I send email use asp.net calvinpost ASP.NET 1.x and 2.0 Application Design 7 April 1st, 2004 09:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.