A problem to send email using Smtp - I don't receive emails by sending emails using smtp

I have a proble to send an email from asp.net

I do the following code to send an email:
MailMessage mail=new MailMessage();
mail.From="test@server.com";
mail.To="myemailaddress@server.com";
mail.BodyFormat=MailFormat.Html;
mail.Subject="testing...";
mail.Body="cool";
SmtpMail.SmtpServer="localhost";
SmtpMail.Send(mail);
But I dont' receive an email when I use this method. Why is that? How can I send an email?
Thanks in advance!
-1
Plato2
1/31/2004 1:58:19 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

8 Replies
2569 Views

Similar Articles

[PageSpeed] 13
Get it on Google Play
Get it on Apple App Store

check and see if..

-your client-side code has no errors
-you imported the System.Web.Mail namespace
-your email is setup right
-your 'localhost' supports smtp..
hope this helps
"programming open-source is programming communism."
-1
lostincode
1/31/2004 3:27:04 AM
I checked IIS it looks like localhost supports smtp(there is a default smtp server?!).

What do you mean I should check if my email is setup right?
Any other ideas.
Thanks
-1
Plato2
1/31/2004 4:01:39 AM
hi , 

you have to set relay in your smtp server , or your smtp server requires username &
password when you are trying to send and emial with .net mail object .
do the following :
go to access tab of of your smtp server properties
on last section there is a relay button , click on it
check all expet the list below . (the list must be blank)
its done .
now check your application , it should work .
ps: im using windows xp , in other version of windows , u have to do the same thing .

1
ariya
1/31/2004 9:12:11 AM
Hi,

Take a look @ Complete FAQ for the System.Web.Mail namespace and view post 268037
HTH

K B Shajudeen
AreYaar.com
Dubai, United Arab Emirates.
1
Shaji
1/31/2004 9:37:49 AM
I did that and it still doesn't work! I opened Badmail folder and all my email are there with the message "Delivery to the following recipients failed."

Any Ideas what to do? Or is there is another way to send emails form asp.net?
Thanks
1
Plato2
1/31/2004 4:23:31 PM
Hi there,

I had the same problem to get my e-mails out to others.
In the end I resolved the problem by changing the SmtpMail.SmtpServer="localhost"; in:
SmtpMail.SmtpServer = Request.ServerVariables("SERVER_NAME").
Also I had to setup my "Default SMTP virtual Server" in IIS in this way:
Enter the IIS module and move to the Relay button in the Access part.
IIS
-<Your website>
--Default SMTP virtual Server -> properties
---TAB Access -> Relay....
----Add your IP adress in this window and Grant "only the list below" which contains your IPadress.
So, by putting the "Request.ServerVariables("SERVER_NAME")" in your code, and set up the proper relay in IIS, the problem was solved.
Success,
Happy programming.
Jos Richters
www.visualdata.nl
"He who pretends to know everything does't know much!" Keep on asking!
1
josrichters
1/31/2004 9:17:36 PM
I did that as you said but it still doesn't work?!?!?!?

Any ideas?
1
Plato2
2/1/2004 4:57:32 PM
When you put the "Request.ServerVariables("SERVER_NAME")"  in (for instance) your FROM field e.g. <MyName>@"Request.ServerVariables("SERVER_NAME")"  you shoud see the servername you are using. In my cas, this is my server's IP adress. So I made the IP adress in the relay-part of IIS exactly the same. Eventually this was the trick in my case. Otherwise you have to retrieve your server's IP adress elsewhere...

good luck!
Jos Richters
www.visualdata.nl
"He who pretends to know everything does't know much!" Keep on asking!
-1
JosRichters
2/2/2004 12:01:25 PM
Reply: