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.