Problem sending email from Webform

M

Mark A. Sam

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("(e-mail address removed)", "(e-mail address removed)", strSubject, strBody) 'Change (e-mail address removed) 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("(e-mail address removed)", txtEmail.Text, "Confirmation", strBody)

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

In the first send, (e-mail address removed) is the recipient and the letter goes through without a problem. In the second, if the value of txtEmail.Text is (e-mail address removed), 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("(e-mail address removed)", 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
 
B

Brendan Green

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("(e-mail address removed)", "(e-mail address removed)", strSubject, strBody) 'Change (e-mail address removed) 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("(e-mail address removed)", txtEmail.Text, "Confirmation", strBody)

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

In the first send, (e-mail address removed) is the recipient and the letter goes through without a problem. In the second, if the value of txtEmail.Text is (e-mail address removed), 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("(e-mail address removed)", 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
 
B

Brendan Green

I pulled this from the MSDN Library:

public static void CreateTestMessage1(string server, int port)
{
string to = "(e-mail address removed)";
string from = "(e-mail address removed)";
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.
 
M

Mark A. Sam

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 = "(e-mail address removed)";
string from = "(e-mail address removed)";
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top