By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

problems by sending email with c# and web.config in a webserver Win 2003

P: n/a
Hi, this is my first time here, but I was looking for something that
may help me, and still, I haven't found something to use.

I'm using a website made in .NET with C#, when I'm running my site from
my PC, everything seems right, but when I publish the website, and send
it to my real website, everything works but the mail sending.

I have red some groups and topics, and everywhere I can found:
- Use the following syntax:
<system.net>
<mailSettings>
<smtp from="on******@yourdomain.com">
<network
host="smtp.yourdomain.com"/>
</smtp>
</mailSettings>
</system.net>
- Or other with some modifications:
<system.net>
<mailSettings>
<smtp from="on******@vyourdomain.com">
<network
host="smtp.yourdomain.com" userName="" password="" port="25"/>
</smtp>
</mailSettings>
</system.net>

Even without the port, it works on my PC, but in the real website, it
doesn't.

I'm not sure if something is missing, my local website is running on a
Windows XP professional edition, with .NET Framework 2.0, and the
website is on a Windows 2003 Server, with the .NET client installed.

Somewhere I red that .NET uses proxy configuration from IE, and I can
use IE in the webserver, but it does not use any proxy.

Also, I can send emails in other way, and THAT way is working anyway,
but this mail settings in the web.config file are showing an error
message.

I tried allowing the port in the firewall, but still nothing.

My questions are:

- Can I have this settings on this file working properly by doing
something in the server, or in the website?
- How can I check the commands sent by my website? Maybe if I can see
the real message, I can figure out a way to make it "recognized". (see
the error mesage below)
- Or, otherwise, can I avoid the mail settings in web.config? Because
when I tried to "avoid its use", by deleting the system.net section,
the website, in my PC, shows a message telling me that this section is
needed.
The error message obtained from the real website is the following:

Error: System.Net.Mail.SmtpException: Syntax error, command
unrecognized. The server response was: Unauthorized relay msg rejected
at System.Net.Mail.RecipientCommand.CheckResponse(Smt pStatusCode
statusCode, String response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Web.UI.WebControls.LoginUtil.SendPasswordMa il(String
email, String userName, String password, MailDefinition mailDefinition,
String defaultSubject, String defaultBody, OnSendingMailDelegate
onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
Control owner)
at
System.Web.UI.WebControls.PasswordRecovery.Attempt SendPasswordUserNameView()
at System.Web.UI.WebControls.PasswordRecovery.Attempt SendPassword()
at System.Web.UI.WebControls.PasswordRecovery.OnBubbl eEvent(Object
source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args)
at System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
By the way, sorry for misspellings, I'm not "english borned".

Thanks for your time, any suggestion or answer is welcome.

Jul 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
This sounds to me like the mail server is rejecting your mail as being
relayed.

see http://www.systemnetmail.com/faq/1.4.aspx for what a relay server is

Most likely it is a setting on the mail server that needs to be changed (or
perhaps you are using the wrong mail server?)

Could you follow the following instructions to grab a log of the connection?
This will show you exactly what your webserver is sending to the email
server and what the email server sends back
http://www.systemnetmail.com/faq/4.10.aspx.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"armando perez" <ar******@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
Hi, this is my first time here, but I was looking for something that
may help me, and still, I haven't found something to use.

I'm using a website made in .NET with C#, when I'm running my site from
my PC, everything seems right, but when I publish the website, and send
it to my real website, everything works but the mail sending.

I have red some groups and topics, and everywhere I can found:
- Use the following syntax:
<system.net>
<mailSettings>
<smtp from="on******@yourdomain.com">
<network
host="smtp.yourdomain.com"/>
</smtp>
</mailSettings>
</system.net>
- Or other with some modifications:
<system.net>
<mailSettings>
<smtp from="on******@vyourdomain.com">
<network
host="smtp.yourdomain.com" userName="" password="" port="25"/>
</smtp>
</mailSettings>
</system.net>

Even without the port, it works on my PC, but in the real website, it
doesn't.

I'm not sure if something is missing, my local website is running on a
Windows XP professional edition, with .NET Framework 2.0, and the
website is on a Windows 2003 Server, with the .NET client installed.

Somewhere I red that .NET uses proxy configuration from IE, and I can
use IE in the webserver, but it does not use any proxy.

Also, I can send emails in other way, and THAT way is working anyway,
but this mail settings in the web.config file are showing an error
message.

I tried allowing the port in the firewall, but still nothing.

My questions are:

- Can I have this settings on this file working properly by doing
something in the server, or in the website?
- How can I check the commands sent by my website? Maybe if I can see
the real message, I can figure out a way to make it "recognized". (see
the error mesage below)
- Or, otherwise, can I avoid the mail settings in web.config? Because
when I tried to "avoid its use", by deleting the system.net section,
the website, in my PC, shows a message telling me that this section is
needed.
The error message obtained from the real website is the following:

Error: System.Net.Mail.SmtpException: Syntax error, command
unrecognized. The server response was: Unauthorized relay msg rejected
at System.Net.Mail.RecipientCommand.CheckResponse(Smt pStatusCode
statusCode, String response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at System.Web.UI.WebControls.LoginUtil.SendPasswordMa il(String
email, String userName, String password, MailDefinition mailDefinition,
String defaultSubject, String defaultBody, OnSendingMailDelegate
onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
Control owner)
at
System.Web.UI.WebControls.PasswordRecovery.Attempt SendPasswordUserNameView()
at System.Web.UI.WebControls.PasswordRecovery.Attempt SendPassword()
at System.Web.UI.WebControls.PasswordRecovery.OnBubbl eEvent(Object
source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args)
at System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
By the way, sorry for misspellings, I'm not "english borned".

Thanks for your time, any suggestion or answer is welcome.

Jul 7 '06 #2

P: n/a
armando perez wrote:
Hi, this is my first time here, but I was looking for something that
may help me, and still, I haven't found something to use.

I'm using a website made in .NET with C#, when I'm running my site from
my PC, everything seems right, but when I publish the website, and send
it to my real website, everything works but the mail sending.
....
The error message obtained from the real website is the following:

Error: System.Net.Mail.SmtpException: Syntax error, command
unrecognized. The server response was: Unauthorized relay msg rejected
at System.Net.Mail.RecipientCommand.CheckResponse(Smt pStatusCode
statusCode, String response)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender,
MailAddressCollection recipients, String deliveryNotify,
....

Hi,
You have the problem with mail relaying. Mail relaying is when recipient
address does not reside on smtp server you connect (it is not local to
server). For example, if smtp server is smtp.domain.com, that server
will reject mails with recipient address other than so*******@domain.com
(eg. so*******@someotherdomain.com) . This is to prevent spam.

Internet providers usually allow relaying for authenticate user. My
does, because I use ADSL connection with authentication, so my providers
smtp server will accept emails to other domains and relay it. This is
because provider can always track emails to me in case of abuse. This
may explain why it works in your test lab.

You have two options:
1. Contact smtp server administrator and explain your situation, they
can allow relaying from your ip address.
2. Do a MX (mail exchanger) record DNS lookup on domain from email
address and deliver to one of smtp servers returned in response.
Regards,
Goran
Jul 7 '06 #3

P: n/a
Thank you for your answers in such a short time.

I will try the log to see what is happening, but it seems that my smtp
provider is the one that I should communicate with.

By the way, I'm still try with other mail sender, and is working now.

I avoid the sender from .NET in the file that was a "forgot password"
kind of, I don't know exactly what happen, but there was a
'CommandName="Submit"' that was trying to send the email with the
properties of web.config file, and that was showing the message.

I erase those words, and make some manual fix, because now, instead of
using the "templates" on .NET for "success", I need to redirect to a
success page.

I appreciate all your help, and I will see if I can set a communication
with my smtp provider, to see what happen, and how can we solve it to
use .NET in a better way.

Thank you all, and I hope this topic can help anyone else that has
something as I had.

Regards, every one!

Have a nice weekend!
(These words were typed on Friday.)

Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.