Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / March 2006

Tip: Looking for answers? Try searching our database.

Problem sending email from Webform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark A. Sam - 21 Mar 2006 13:41 GMT
Hello,

I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website.

I was having difficulty finding a relay server to SMTP though, but was able to do this though one of my personal account, Cabbage.Org.  It doesn't make any sense to me why this works and no other account, including localhost and the remote server which hosts the website.

Here is a code snippet showing the sending of both emails:

**************************
Dim MailObj As New System.Net.Mail.SmtpClient

MailObj.Host = "smtp.youthkaraoke.org"

MailObj.Send("mail@dragonimports.com", "msam@cabbage.org", strSubject, strBody) 'Change msam@Truckloads.Net to working email

'Send confirmation to sender

strBody = "Thank you for submitting your request to Dragon Importing" + vbNewLine + _

"You will be contacted soon by one of our reprresentives!" + vbNewLine + vbNewLine + _

"The Dragon Importing Staff"

MailObj.Send("mail@dragonimports.com", txtEmail.Text, "Confirmation", strBody)

*********************************

In the first send, msam@cabbage.org is the recipient and the letter goes through without a problem.  In the second, if the value of txtEmail.Text is msam@cabbage.org, then no problem either, but if any other email address is used then I get this error:



Server Error in '/' Application.
--------------------------------------------------------------------------------

Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected

Source Error:

Line 79:                 "You will be contacted soon by one of our reprresentives!" + vbNewLine + vbNewLine + _
Line 80:                 "The Dragon Importing Staff"
Line 81:       MailObj.Send("mail@dragonimports.com", txtEmail.Text, "Confirmation", strBody)
Line 82:
Line 83:  

Source File: C:\Domains\dragonimporting.com\wwwroot\Contact.aspx.vb    Line: 81

Stack Trace:

[SmtpException: Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected ]


Any help I can get is appreciated.

Thank you and God Bless,

Mark A. Sma
Sonu Kapoor [MVP] - 21 Mar 2006 15:34 GMT
Have you already checked on www.systemwebmail.com ?

Sonu Kapoor [MVP]
Brendan Green - 21 Mar 2006 22:39 GMT
You probably need to supply a username and password to relay messages through that SMTP server.
 Hello,

 I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website.

 I was having difficulty finding a relay server to SMTP though, but was able to do this though one of my personal account, Cabbage.Org.  It doesn't make any sense to me why this works and no other account, including localhost and the remote server which hosts the website.

 Here is a code snippet showing the sending of both emails:

 **************************
 Dim MailObj As New System.Net.Mail.SmtpClient

 MailObj.Host = "smtp.youthkaraoke.org"

 MailObj.Send("mail@dragonimports.com", "msam@cabbage.org", strSubject, strBody) 'Change msam@Truckloads.Net to working email

 'Send confirmation to sender

 strBody = "Thank you for submitting your request to Dragon Importing" + vbNewLine + _

 "You will be contacted soon by one of our reprresentives!" + vbNewLine + vbNewLine + _

 "The Dragon Importing Staff"

 MailObj.Send("mail@dragonimports.com", txtEmail.Text, "Confirmation", strBody)

 *********************************

 In the first send, msam@cabbage.org is the recipient and the letter goes through without a problem.  In the second, if the value of txtEmail.Text is msam@cabbage.org, then no problem either, but if any other email address is used then I get this error:

 Server Error in '/' Application.
------------------------------------------------------------------------------

 Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected
 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

 Exception Details: System.Net.Mail.SmtpException: Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected

 Source Error:

Line 79:                 "You will be contacted soon by one of our reprresentives!" + vbNewLine + vbNewLine + _
Line 80:                 "The Dragon Importing Staff"
Line 81:       MailObj.Send("mail@dragonimports.com", txtEmail.Text, "Confirmation", strBody)
Line 82:
Line 83:  

 Source File: C:\Domains\dragonimporting.com\wwwroot\Contact.aspx.vb    Line: 81

 Stack Trace:

[SmtpException: Syntax error, command unrecognized. The server response was: Unauthorized relay msg rejected ]


 Any help I can get is appreciated.

 Thank you and God Bless,

 Mark A. Sma
Mark A. Sam - 21 Mar 2006 22:53 GMT
Thanks Brendan.   Do you know how do to that?  I can't seem to find an example.
Brendan Green - 22 Mar 2006 02:20 GMT
I pulled this from the MSDN Library:

public static void CreateTestMessage1(string server, int port)
{
   string to = "jane@contoso.com";
   string from = "ben@contoso.com";
   string subject = "Using the new SMTP client.";
   string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
   MailMessage message = new MailMessage(from, to, subject, body);
   SmtpClient client = new SmtpClient(server, port);
   // Credentials are necessary if the server requires the client
   // to authenticate before it will send e-mail on the client's behalf.
   client.Credentials = CredentialCache.DefaultNetworkCredentials;

   client.Send(message);
}

Instead of using DefaultNetworkCredentials, specify the appropriate username/password.
 Thanks Brendan.   Do you know how do to that?  I can't seem to find an example.
Mark A. Sam - 22 Mar 2006 07:52 GMT
Thanks Brendan.  I changed to a different hosting company, which solved the problem.  It accepted LocalHost.

 I pulled this from the MSDN Library:

 public static void CreateTestMessage1(string server, int port)
 {
     string to = "jane@contoso.com";
     string from = "ben@contoso.com";
     string subject = "Using the new SMTP client.";
     string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
     MailMessage message = new MailMessage(from, to, subject, body);
     SmtpClient client = new SmtpClient(server, port);
     // Credentials are necessary if the server requires the client
     // to authenticate before it will send e-mail on the client's behalf.
     client.Credentials = CredentialCache.DefaultNetworkCredentials;

     client.Send(message);
 }

 Instead of using DefaultNetworkCredentials, specify the appropriate username/password.
   "Mark A. Sam" <msam@Plan-It-Earth.Net> wrote in message news:ugJlLHTTGHA.4452@TK2MSFTNGP12.phx.gbl...
   Thanks Brendan.   Do you know how do to that?  I can't seem to find an example.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.