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

A

armando perez

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="(e-mail address removed)">
<network
host="smtp.yourdomain.com"/>
</smtp>
</mailSettings>
</system.net>
- Or other with some modifications:
<system.net>
<mailSettings>
<smtp from="(e-mail address removed)">
<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(SmtpStatusCode
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.SendPasswordMail(String
email, String userName, String password, MailDefinition mailDefinition,
String defaultSubject, String defaultBody, OnSendingMailDelegate
onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate,
Control owner)
at
System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordUserNameView()
at System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword()
at System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object
source, EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
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.
 
G

Greg Young

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
 
G

Goran Sliskovic

armando said:
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(SmtpStatusCode
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 (e-mail address removed)
(eg. (e-mail address removed)) . 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
 
A

armando perez

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.)
 

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