473,549 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SmtpFailedRecip ientException + asp.net 2.0

3 New Member
Hi

I have been having problems with smptclient in asp.net 2.0(C#). I found everytime I put a fake email address or any dodgy ones, it nevers calls SmtpFailedRecip ientException in the catch statement. Any ideas why please?

This is my coding:
Expand|Select|Wrap|Line Numbers
  1. try
  2.             {
  3.                 MailAddress fromAddress = new MailAddress(From, Name);
  4.                 //***You can specify the host name or ipaddress of your server
  5.                 //***Default in IIS will be localhost 
  6.                 smtpClient.Host = Host;
  7.                 //***Default port will be 25
  8.                 smtpClient.Port = Port;
  9.                 smtpClient.DeliveryMethod = smtpSec.DeliveryMethod;
  10.                 smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;
  11.                 smtpClient.UseDefaultCredentials = smtpSec.Network.DefaultCredentials;
  12.                 smtpClient.EnableSsl = false;
  13.                 //***From address will be given as a MailAddress Object
  14.                 oMsg.From = fromAddress;
  15.                 oMsg.Subject = Subject;
  16.                 //***Body can be Html or text format
  17.                 //***Specify true if it  is html message
  18.                 oMsg.IsBodyHtml = EmailBodyFormat;
  19.                 oMsg.Body = EmailBodyText;
  20.  
  21.  
  22.                //***To address collection of MailAddress
  23.               oMsg.To.Add(UsersEmail);
  24.  
  25.                 //***Send SMTP mail
  26.                 smtpClient.Send(oMsg);
  27.                 oMsg = null;
  28.             }
  29.             catch(SmtpFailedRecipientException sfrex)
  30.             {
  31.                 //***The SMTP Server is refusing to forward the Message
  32.             }
  33.  
Can you tell me what could be done? and any examples of coding for me resolve this issue? I have been trying various approaches for several days but to no avail, it does not go to the catch statement.

Thanks

Newbie
Jun 27 '07 #1
5 2708
Frinavale
9,735 Recognized Expert Moderator Expert
Hi

I have been having problems with smptclient in asp.net 2.0(C#). I found everytime I put a fake email address or any dodgy ones, it nevers calls SmtpFailedRecip ientException in the catch statement. Any ideas why please?

This is my coding:

Can you tell me what could be done? and any examples of coding for me resolve this issue? I have been trying various approaches for several days but to no avail, it does not go to the catch statement.

Thanks

Newbie
Hey there!
I think the reason why it never calls the SmtpFailedRecip ientException catch statement is because it may be throwing a different type of exception.

From what I understand the SmtpClient could be throwing a general SmtpException. Using this Exception you can determine what went wrong by checking the status...

See MSDN for more on the topic.

Cheers!

-Frinny
Jun 27 '07 #2
MorpheusX
3 New Member
Actually I put all the error exceptions - it nevers picks any of them including the SmtpFailedRecip ientException as well.
Expand|Select|Wrap|Line Numbers
  1.   catch(SmtpFailedRecipientException sfrex)
  2.             {
  3.                 //***The SMTP Server is refusing to forward the Message
  4.             }
  5.             catch (System.Net.Mail.SmtpException exSmtp)
  6.             {
  7.                 //***Communication with SMTP Server Failed    
  8.  
  9.             }
  10.             catch (System.Net.Sockets.SocketException exp)
  11.             {
  12.  
  13.             }
  14.             catch (System.ComponentModel.Win32Exception exp)
  15.             {
  16.  
  17.             }
  18.             catch (System.Exception exp)
  19.             {
  20.  
  21.             }
  22.  

Any ideas please..... Would really help me in an immense way.

Thanks Newbie
Jun 27 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
Actually I put all the error exceptions - it nevers picks any of them including the SmtpFailedRecip ientException as well.


Any ideas please..... Would really help me in an immense way.

Thanks Newbie
The SmtpFailedRecip ientException
Represents the exception that is thrown when the SmtpClient is not able to complete a Send or SendAsync operation to a particular recipient.
This means that if your SMTP server sends the email and it is never received (because it is a bogus email address), no exception happens. An exception only happens when the SmtpClient (your code) can't send to the SMTP server. When you send an email to an email address that doesn't exist, every thing's fine...the PostMaster will send you an email back saying that the message wasn't delivered but your message sent perfectly fine!

-Frinny
Jun 27 '07 #4
MorpheusX
3 New Member
I understand now what you said made sense perfectly. But what I was hoping was even if a bogus email address gets sent and recieved perfectly. Is there no way to detect the email is in fact a bogus. Cos I was hoping to trap all the bogus email address or bounced email address to an XML log.

Any ideas? I have tried TCPClient and Socket - but they are not very effective either.

Any help will be immensely appreciated.

Thanks

Newbie.
Jun 28 '07 #5
Frinavale
9,735 Recognized Expert Moderator Expert
I don't know if this will help you.
But check out this thread.

-Frinny
Jun 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
19863
by: Gerhard | last post by:
Hi, I some asp.net beta 2 code that works fine on an XP Pro machine, but on a Windows 2003 Server gets the following error: System.Net.Mail.SmtpFailedRecipientException {"Mailbox unavailable. The server response was: 5.7.1 <veachb@quixnet.net>... Relaying denied. IP name possibly forged "} System.Net.Mail.SmtpFailedRecipientException
6
2088
by: RonL | last post by:
What is the recommended best technique for handling errors/exceptions in ASP.Net. I've read about the following techniques: 1. Try/Catch 2. Page_Error 3. Application_Error in the glabal.asax 4. Custom errors in Web.Config.
0
2581
by: Smokey Grindle | last post by:
I am using the user creation wizard in asp.net 2.0 and using it to send the user an email message when their account is created, well this works great if the address is a valid mailbox, but when it is not it throws an exception (shown below) how do i prevent this? Description: System.Web.HttpUnhandledException: Exception of type...
1
5030
by: shapper | last post by:
Hello, I created an ASP.NET 2.0 custom control which includes various TextBoxes, Labels and a button. Basically is a contact form. When the button is pressed the values are sent by email. I want to use the mailSettings values in my Web.Config file. Everything works fine if I use in my bSubmit function:
1
4296
by: vbMark | last post by:
Hello, I am able to make a contact form for my site no problem--it works great. However, I am making a contact form so that customers can reach other members who have registered on my site. The problem I am running into is this, when the SmptClient.Send tries to send to an email address not on my mail server I get this message: ...
8
7267
by: shapper | last post by:
Hello, I am trying to send an email using Asp.Net 2.0. I am getting the following error: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such user here at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify,
4
10851
by: Fabio Visin | last post by:
Hi! I'm studing SmtpFailedRecipientException to trap errors when I'm sending e-mail. I modified a sample code founded on MSDN so: public static void errorMail() { MailAddress from = new MailAddress("fabio.visin@xxx.it"); MailAddress to = new MailAddress("webmaster@xxx.it"); MailMessage message = new MailMessage(from, to); message.Subject...
3
1469
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I have the following code to send an email and I get this error: . The error is on at last line below. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress("myMail@anyHost.com", "POS-eTive Point of Sales."); // host name of server
0
2711
by: Velvet | last post by:
Our staging server has several web sites that send emails. Most of the sites can send email but one of them is gettting the following message when HTML formatted email is sent. We created a test page and verifyied that the exact same code works on another website but not this one. The interesting thing is that the email is in fact sent and...
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7957
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6043
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.