473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SmtpMail.Send() No Error but no Email either.

Hi,

I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.

I'm using my local default SMTP Server and my from address is a valid
Yahoo/Hotmail address. I have configures the local SMTP Server to allow
the IP Address 127.0.0.1.

Could this be because yahoo/hotmail servers need authentication?

Here's the code I use.

private void SendSimpleMail()
{

MailMessage objEmail = New MailMessage();
objEmail.From = "va******@yahoo.com";
objEmail.To = "an**************@hotmail.com";
objEmail.Subject = "Test Mail";
objEmail.Body = "Test Mail - Body";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(objEmail);

}
Any idea what could be wrong or what I need to do to send a simple
email from ASP.NET? Any help would be appreaciated.

Regards,
supz

Feb 27 '06 #1
14 9090
"supz" <su****@yahoo.com> wrote in message
news:11*********************@t39g2000cwt.googlegro ups.com...
Could this be because yahoo/hotmail servers need authentication?


www.systemwebmail.com
Feb 27 '06 #2
You may have forgotton to set up your smart host settings in smtp under iis.
This tells IIS how to route the SMTP message, in effect who to pass it to
for onward delivery.

--
Regards

John Timney
Microsoft MVP

"supz" <su****@yahoo.com> wrote in message
news:11*********************@t39g2000cwt.googlegro ups.com...
Hi,

I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.

I'm using my local default SMTP Server and my from address is a valid
Yahoo/Hotmail address. I have configures the local SMTP Server to allow
the IP Address 127.0.0.1.

Could this be because yahoo/hotmail servers need authentication?

Here's the code I use.

private void SendSimpleMail()
{

MailMessage objEmail = New MailMessage();
objEmail.From = "va******@yahoo.com";
objEmail.To = "an**************@hotmail.com";
objEmail.Subject = "Test Mail";
objEmail.Body = "Test Mail - Body";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(objEmail);

}
Any idea what could be wrong or what I need to do to send a simple
email from ASP.NET? Any help would be appreaciated.

Regards,
supz

Feb 27 '06 #3
Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?

Feb 27 '06 #4
re:
If I send using a "yahoo" address in the "from" field,
is it the responsibilty of the Yahoo server to deliver the mail?
No, it is not.
The mail will be delivered to the "TO:" address by your SMTP server.

re: do I really need to set up the smart host settings?
You don't have to use a smart host, although sometimes it's better to use one.
Not all the time, though.

re:I read somewhere that the local SMTP server sends the mail
to the relay server which will send the email to the recipient.
Only if you use an external SMPT server.
If you use your own smtp server, *it* will send the mail.

The thing is that you must configure your smtp server so it:

1. can be found by the .Net Framework
2. allows mail relay only from certain IPs or machines.
Otherwise, anyubody can use *your* smtp server to send *their* mail.
Spammers would love it if you opened your smtp server so the could send their spam.

Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in the IIS Manager ).

This is extremely important.

They should be *both* set to your IP address.

Also, in the "Delivery" tab, in the "Advanced" button,
you can, optionally, set the domain name, if you have one.

Then, in your code, assign your machine name or domain name to the smtp client :

For ASP.NET 2.0 :
Dim client As New SmtpClient("yourmachinename")
client.Send(mail)

For ASP.NET 1.1 :
System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your domain name"
System.Web.Mail.SmtpMail.Send(mail)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com... Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?

Feb 27 '06 #5
You can try to replace the smtp device

SmtpMail.SmtpServer = "mail.yahoo.co.uk";

It migth still fail though, yahoo probably requires a username and password
to forward mail through it and you might need to use a thrid party component
http://www.aspnetemail.com/

or if your using .net 1.1 or above

private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "yo*@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",
"1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",
"my_username_here"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",
"super_secret"); //set your password here

SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}
taken from http://www.systemwebmail.com/faq/3.8.aspx

--
Regards

John Timney
Microsoft MVP

"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?

Feb 27 '06 #6
KMA
Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a
message. Then the site sends the message via email to my private address.
Now, it all works fine, but I've got a nagging feeling because it works from
both my local test machine and the shared host. But I never specify any
password, and I'm worrying that anybody could send mail. since I'm on shared
hosting I don't get access to IIS. I thought at first that it would only
work on the host (some kind of permission for the ASP.NET worker process)
but it works local too. I'm worried. What can I do?

BTW the code is lifted straight from many examples from the web and is
almost identical to what you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
re:
If I send using a "yahoo" address in the "from" field,
is it the responsibilty of the Yahoo server to deliver the mail?


No, it is not.
The mail will be delivered to the "TO:" address by your SMTP server.

re:
do I really need to set up the smart host settings?


You don't have to use a smart host, although sometimes it's better to use
one.
Not all the time, though.

re:
I read somewhere that the local SMTP server sends the mail
to the relay server which will send the email to the recipient.


Only if you use an external SMPT server.
If you use your own smtp server, *it* will send the mail.

The thing is that you must configure your smtp server so it:

1. can be found by the .Net Framework
2. allows mail relay only from certain IPs or machines.
Otherwise, anyubody can use *your* smtp server to send *their* mail.
Spammers would love it if you opened your smtp server so the could send
their spam.

Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in the
IIS Manager ).

This is extremely important.

They should be *both* set to your IP address.

Also, in the "Delivery" tab, in the "Advanced" button,
you can, optionally, set the domain name, if you have one.

Then, in your code, assign your machine name or domain name to the smtp
client :

For ASP.NET 2.0 :
Dim client As New SmtpClient("yourmachinename")
client.Send(mail)

For ASP.NET 1.1 :
System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your domain
name"
System.Web.Mail.SmtpMail.Send(mail)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?


Feb 27 '06 #7

See my blog entry:
http://spaces.msn.com/sholliday/
2/8/2006
Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)
I have
No(authentication)
Basic
and
SSL
gmail is the example I use....you might want to get an gmail account and use
it,,if the yahoo keeps failing.

"supz" <su****@yahoo.com> wrote in message
news:11*********************@t39g2000cwt.googlegro ups.com...
Hi,

I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.

I'm using my local default SMTP Server and my from address is a valid
Yahoo/Hotmail address. I have configures the local SMTP Server to allow
the IP Address 127.0.0.1.

Could this be because yahoo/hotmail servers need authentication?

Here's the code I use.

private void SendSimpleMail()
{

MailMessage objEmail = New MailMessage();
objEmail.From = "va******@yahoo.com";
objEmail.To = "an**************@hotmail.com";
objEmail.Subject = "Test Mail";
objEmail.Body = "Test Mail - Body";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(objEmail);

}
Any idea what could be wrong or what I need to do to send a simple
email from ASP.NET? Any help would be appreaciated.

Regards,
supz

Feb 27 '06 #8

PS

If you get the yahoo settings worked out...with my code from my blog.
Could you post a reply here...and a comment at the blog on which settings
you used.

Thanks...
"supz" <su****@yahoo.com> wrote in message
news:11*********************@t39g2000cwt.googlegro ups.com...
Hi,

I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.

I'm using my local default SMTP Server and my from address is a valid
Yahoo/Hotmail address. I have configures the local SMTP Server to allow
the IP Address 127.0.0.1.

Could this be because yahoo/hotmail servers need authentication?

Here's the code I use.

private void SendSimpleMail()
{

MailMessage objEmail = New MailMessage();
objEmail.From = "va******@yahoo.com";
objEmail.To = "an**************@hotmail.com";
objEmail.Subject = "Test Mail";
objEmail.Body = "Test Mail - Body";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(objEmail);

}
Any idea what could be wrong or what I need to do to send a simple
email from ASP.NET? Any help would be appreaciated.

Regards,
supz

Feb 27 '06 #9
re:
I'm worrying that anybody could send mail
In fact, anybody who can view that page will be able to send mail to you.

If you've hard-coded the address you need not worry,
except for the occasional spambot which will send you spam.

If you haven't hard-coded the address
( if you use a textbox for the user to write in the email address )
then anybody could send an email to anybody else, and you could
be the victim of an automated spam-sending scheme.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message news:dt**********@atlas.ip-plus.net... Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a message. Then the site sends
the message via email to my private address. Now, it all works fine, but I've got a nagging
feeling because it works from both my local test machine and the shared host. But I never specify
any password, and I'm worrying that anybody could send mail. since I'm on shared hosting I don't
get access to IIS. I thought at first that it would only work on the host (some kind of permission
for the ASP.NET worker process) but it works local too. I'm worried. What can I do?

BTW the code is lifted straight from many examples from the web and is almost identical to what
you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
re:
If I send using a "yahoo" address in the "from" field,
is it the responsibilty of the Yahoo server to deliver the mail?


No, it is not.
The mail will be delivered to the "TO:" address by your SMTP server.

re:
do I really need to set up the smart host settings?


You don't have to use a smart host, although sometimes it's better to use one.
Not all the time, though.

re:
I read somewhere that the local SMTP server sends the mail
to the relay server which will send the email to the recipient.


Only if you use an external SMPT server.
If you use your own smtp server, *it* will send the mail.

The thing is that you must configure your smtp server so it:

1. can be found by the .Net Framework
2. allows mail relay only from certain IPs or machines.
Otherwise, anyubody can use *your* smtp server to send *their* mail.
Spammers would love it if you opened your smtp server so the could send their spam.

Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in the IIS Manager ).

This is extremely important.

They should be *both* set to your IP address.

Also, in the "Delivery" tab, in the "Advanced" button,
you can, optionally, set the domain name, if you have one.

Then, in your code, assign your machine name or domain name to the smtp client :

For ASP.NET 2.0 :
Dim client As New SmtpClient("yourmachinename")
client.Send(mail)

For ASP.NET 1.1 :
System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your domain name"
System.Web.Mail.SmtpMail.Send(mail)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?



Feb 27 '06 #10
KMA
Juan,

Thanks for the quick reply.

Just to clarify, *my* ASP.NET program has the recipient address hard coded
to me at co*********@mydomain.com, so no problem there. And of course anyone
can spam me through the contact form, or indeed simply by putting
sa***@mydomain.com etc. This much is clear and unavoidable.

But, from what I can tell, if *you* wrote a test ASP.NET app, and copied and
pasted my code from my project (or even if you knew the domain) then you
could spam whoever you want through my shared hosts SMTP server. The problem
is I can't find where the security is set. Surely they don't just leave this
kind of hole open, do they?

Hopefully I've explained myself better now.

Thanks for the quick reply.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
re:
I'm worrying that anybody could send mail


In fact, anybody who can view that page will be able to send mail to you.

If you've hard-coded the address you need not worry,
except for the occasional spambot which will send you spam.

If you haven't hard-coded the address
( if you use a textbox for the user to write in the email address )
then anybody could send an email to anybody else, and you could
be the victim of an automated spam-sending scheme.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message
news:dt**********@atlas.ip-plus.net...
Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a
message. Then the site sends the message via email to my private address.
Now, it all works fine, but I've got a nagging feeling because it works
from both my local test machine and the shared host. But I never specify
any password, and I'm worrying that anybody could send mail. since I'm on
shared hosting I don't get access to IIS. I thought at first that it
would only work on the host (some kind of permission for the ASP.NET
worker process) but it works local too. I'm worried. What can I do?

BTW the code is lifted straight from many examples from the web and is
almost identical to what you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
re:
If I send using a "yahoo" address in the "from" field,
is it the responsibilty of the Yahoo server to deliver the mail?

No, it is not.
The mail will be delivered to the "TO:" address by your SMTP server.

re:
do I really need to set up the smart host settings?

You don't have to use a smart host, although sometimes it's better to
use one.
Not all the time, though.

re:
I read somewhere that the local SMTP server sends the mail
to the relay server which will send the email to the recipient.

Only if you use an external SMPT server.
If you use your own smtp server, *it* will send the mail.

The thing is that you must configure your smtp server so it:

1. can be found by the .Net Framework
2. allows mail relay only from certain IPs or machines.
Otherwise, anyubody can use *your* smtp server to send *their* mail.
Spammers would love it if you opened your smtp server so the could send
their spam.

Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in
the IIS Manager ).

This is extremely important.

They should be *both* set to your IP address.

Also, in the "Delivery" tab, in the "Advanced" button,
you can, optionally, set the domain name, if you have one.

Then, in your code, assign your machine name or domain name to the smtp
client :

For ASP.NET 2.0 :
Dim client As New SmtpClient("yourmachinename")
client.Send(mail)

For ASP.NET 1.1 :
System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your domain
name"
System.Web.Mail.SmtpMail.Send(mail)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks for your prompt replies. This might be a stupid quuestion, but
do I really need to set up the smart host settings? I read somewhere
that the local SMTP server sends the mail to the relay server which
will send the email to the recipient. If I send using a "yahoo" address
in the "from" field, is it the responsibilty of the Yahoo server to
deliver the mail?



Feb 27 '06 #11
re:
But, from what I can tell, if *you* wrote a test ASP.NET app, and copied and pasted my code from
my project (or even if you knew the domain) then you could spam whoever you want through my shared
hosts SMTP server.
Not really. See below.

re: The problem is I can't find where the security is set. Surely they don't just leave this kind of
hole open, do they?
Your SMTP server should have its "Relay Restrictions" set.

If you set the relay restrictions to only allow traffic from the same machine IP
as your smtp server, your smtp server can't be used by external spammers.

In the IIS Manager, after opening the smtp server's properties,
you'll find the "Relay Restrictions" dialog in the "Access" tab.

If you don't have access to the IIS Manager, ask your provider
about the Relay restrictions they have in place.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message news:dt**********@atlas.ip-plus.net... Juan,

Thanks for the quick reply.

Just to clarify, *my* ASP.NET program has the recipient address hard coded to me at
co*********@mydomain.com, so no problem there. And of course anyone can spam me through the
contact form, or indeed simply by putting sa***@mydomain.com etc. This much is clear and
unavoidable.

But, from what I can tell, if *you* wrote a test ASP.NET app, and copied and pasted my code from
my project (or even if you knew the domain) then you could spam whoever you want through my shared
hosts SMTP server. The problem is I can't find where the security is set. Surely they don't just
leave this kind of hole open, do they?

Hopefully I've explained myself better now.

Thanks for the quick reply.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
re:
I'm worrying that anybody could send mail


In fact, anybody who can view that page will be able to send mail to you.

If you've hard-coded the address you need not worry,
except for the occasional spambot which will send you spam.

If you haven't hard-coded the address
( if you use a textbox for the user to write in the email address )
then anybody could send an email to anybody else, and you could
be the victim of an automated spam-sending scheme.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message news:dt**********@atlas.ip-plus.net...
Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a message. Then the site
sends the message via email to my private address. Now, it all works fine, but I've got a
nagging feeling because it works from both my local test machine and the shared host. But I
never specify any password, and I'm worrying that anybody could send mail. since I'm on shared
hosting I don't get access to IIS. I thought at first that it would only work on the host (some
kind of permission for the ASP.NET worker process) but it works local too. I'm worried. What can
I do?

BTW the code is lifted straight from many examples from the web and is almost identical to what
you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
re:
> If I send using a "yahoo" address in the "from" field,
> is it the responsibilty of the Yahoo server to deliver the mail?

No, it is not.
The mail will be delivered to the "TO:" address by your SMTP server.

re:
> do I really need to set up the smart host settings?

You don't have to use a smart host, although sometimes it's better to use one.
Not all the time, though.

re:
>I read somewhere that the local SMTP server sends the mail
> to the relay server which will send the email to the recipient.

Only if you use an external SMPT server.
If you use your own smtp server, *it* will send the mail.

The thing is that you must configure your smtp server so it:

1. can be found by the .Net Framework
2. allows mail relay only from certain IPs or machines.
Otherwise, anyubody can use *your* smtp server to send *their* mail.
Spammers would love it if you opened your smtp server so the could send their spam.

Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in the IIS Manager ).

This is extremely important.

They should be *both* set to your IP address.

Also, in the "Delivery" tab, in the "Advanced" button,
you can, optionally, set the domain name, if you have one.

Then, in your code, assign your machine name or domain name to the smtp client :

For ASP.NET 2.0 :
Dim client As New SmtpClient("yourmachinename")
client.Send(mail)

For ASP.NET 1.1 :
System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your domain name"
System.Web.Mail.SmtpMail.Send(mail)

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"supz" <su****@yahoo.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
> Thanks for your prompt replies. This might be a stupid quuestion, but
> do I really need to set up the smart host settings? I read somewhere
> that the local SMTP server sends the mail to the relay server which
> will send the email to the recipient. If I send using a "yahoo" address
> in the "from" field, is it the responsibilty of the Yahoo server to
> deliver the mail?
>



Feb 27 '06 #12
KMA

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uO**************@TK2MSFTNGP11.phx.gbl...
re:
But, from what I can tell, if *you* wrote a test ASP.NET app, and copied
and pasted my code from my project (or even if you knew the domain) then
you could spam whoever you want through my shared hosts SMTP server.
Not really. See below.

re:
The problem is I can't find where the security is set. Surely they don't
just leave this kind of hole open, do they?


Your SMTP server should have its "Relay Restrictions" set.

If you set the relay restrictions to only allow traffic from the same
machine IP
as your smtp server, your smtp server can't be used by external spammers.

In the IIS Manager, after opening the smtp server's properties,
you'll find the "Relay Restrictions" dialog in the "Access" tab.

If you don't have access to the IIS Manager, ask your provider
about the Relay restrictions they have in place.


Thanks Juan.

I'm definitely going to do this. I could understand if I were unable to send
locally while testing. Hopefully the local test only works because I'm
already "hidden" logged in through my email client. I'll have to
investigate. Thanks for pointing me down the right road. At least I can
explain the problem to the shared host easier now.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message
news:dt**********@atlas.ip-plus.net...
Juan,

Thanks for the quick reply.

Just to clarify, *my* ASP.NET program has the recipient address hard
coded to me at co*********@mydomain.com, so no problem there. And of
course anyone can spam me through the contact form, or indeed simply by
putting sa***@mydomain.com etc. This much is clear and unavoidable.

But, from what I can tell, if *you* wrote a test ASP.NET app, and copied
and pasted my code from my project (or even if you knew the domain) then
you could spam whoever you want through my shared hosts SMTP server. The
problem is I can't find where the security is set. Surely they don't just
leave this kind of hole open, do they?

Hopefully I've explained myself better now.

Thanks for the quick reply.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
re:
I'm worrying that anybody could send mail

In fact, anybody who can view that page will be able to send mail to
you.

If you've hard-coded the address you need not worry,
except for the occasional spambot which will send you spam.

If you haven't hard-coded the address
( if you use a textbox for the user to write in the email address )
then anybody could send an email to anybody else, and you could
be the victim of an automated spam-sending scheme.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message
news:dt**********@atlas.ip-plus.net...
Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a
message. Then the site sends the message via email to my private
address. Now, it all works fine, but I've got a nagging feeling because
it works from both my local test machine and the shared host. But I
never specify any password, and I'm worrying that anybody could send
mail. since I'm on shared hosting I don't get access to IIS. I thought
at first that it would only work on the host (some kind of permission
for the ASP.NET worker process) but it works local too. I'm worried.
What can I do?

BTW the code is lifted straight from many examples from the web and is
almost identical to what you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
> re:
>> If I send using a "yahoo" address in the "from" field,
>> is it the responsibilty of the Yahoo server to deliver the mail?
>
> No, it is not.
> The mail will be delivered to the "TO:" address by your SMTP server.
>
> re:
>> do I really need to set up the smart host settings?
>
> You don't have to use a smart host, although sometimes it's better to
> use one.
> Not all the time, though.
>
> re:
>>I read somewhere that the local SMTP server sends the mail
>> to the relay server which will send the email to the recipient.
>
> Only if you use an external SMPT server.
> If you use your own smtp server, *it* will send the mail.
>
> The thing is that you must configure your smtp server so it:
>
> 1. can be found by the .Net Framework
> 2. allows mail relay only from certain IPs or machines.
> Otherwise, anyubody can use *your* smtp server to send *their* mail.
> Spammers would love it if you opened your smtp server so the could
> send their spam.
>
> Have you set the "Connection control" and "Relay Restrictions" ?
> ( in the "Access" tab...after opening the smtp server's properties in
> the IIS Manager ).
>
> This is extremely important.
>
> They should be *both* set to your IP address.
>
> Also, in the "Delivery" tab, in the "Advanced" button,
> you can, optionally, set the domain name, if you have one.
>
> Then, in your code, assign your machine name or domain name to the
> smtp client :
>
> For ASP.NET 2.0 :
> Dim client As New SmtpClient("yourmachinename")
> client.Send(mail)
>
> For ASP.NET 1.1 :
> System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your
> domain name"
> System.Web.Mail.SmtpMail.Send(mail)
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "supz" <su****@yahoo.com> wrote in message
> news:11**********************@u72g2000cwu.googlegr oups.com...
>> Thanks for your prompt replies. This might be a stupid quuestion, but
>> do I really need to set up the smart host settings? I read somewhere
>> that the local SMTP server sends the mail to the relay server which
>> will send the email to the recipient. If I send using a "yahoo"
>> address
>> in the "from" field, is it the responsibilty of the Yahoo server to
>> deliver the mail?
>>
>
>



Feb 27 '06 #13
KMA
Juan,

Just an update. It appears that, locally at least, I can only forward to
addresses in the same (my) domain. At least this puts my mind at rest
regarding people spamming others through me. I could still get loads of
spam, but then again I get loads anyway.

Cheers.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uO**************@TK2MSFTNGP11.phx.gbl...
re:
But, from what I can tell, if *you* wrote a test ASP.NET app, and copied
and pasted my code from my project (or even if you knew the domain) then
you could spam whoever you want through my shared hosts SMTP server.


Not really. See below.

re:
The problem is I can't find where the security is set. Surely they don't
just leave this kind of hole open, do they?


Your SMTP server should have its "Relay Restrictions" set.

If you set the relay restrictions to only allow traffic from the same
machine IP
as your smtp server, your smtp server can't be used by external spammers.

In the IIS Manager, after opening the smtp server's properties,
you'll find the "Relay Restrictions" dialog in the "Access" tab.

If you don't have access to the IIS Manager, ask your provider
about the Relay restrictions they have in place.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message
news:dt**********@atlas.ip-plus.net...
Juan,

Thanks for the quick reply.

Just to clarify, *my* ASP.NET program has the recipient address hard
coded to me at co*********@mydomain.com, so no problem there. And of
course anyone can spam me through the contact form, or indeed simply by
putting sa***@mydomain.com etc. This much is clear and unavoidable.

But, from what I can tell, if *you* wrote a test ASP.NET app, and copied
and pasted my code from my project (or even if you knew the domain) then
you could spam whoever you want through my shared hosts SMTP server. The
problem is I can't find where the security is set. Surely they don't just
leave this kind of hole open, do they?

Hopefully I've explained myself better now.

Thanks for the quick reply.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
re:
I'm worrying that anybody could send mail

In fact, anybody who can view that page will be able to send mail to
you.

If you've hard-coded the address you need not worry,
except for the occasional spambot which will send you spam.

If you haven't hard-coded the address
( if you use a textbox for the user to write in the email address )
then anybody could send an email to anybody else, and you could
be the victim of an automated spam-sending scheme.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"KMA" <km*@schneeberger.ch> wrote in message
news:dt**********@atlas.ip-plus.net...
Juan,

Can you explain this a bit more.

I've just made a contact page for my site to allow people to write a
message. Then the site sends the message via email to my private
address. Now, it all works fine, but I've got a nagging feeling because
it works from both my local test machine and the shared host. But I
never specify any password, and I'm worrying that anybody could send
mail. since I'm on shared hosting I don't get access to IIS. I thought
at first that it would only work on the host (some kind of permission
for the ASP.NET worker process) but it works local too. I'm worried.
What can I do?

BTW the code is lifted straight from many examples from the web and is
almost identical to what you've posted below. (1.1 version).

Thankyou.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:O7**************@TK2MSFTNGP09.phx.gbl...
> re:
>> If I send using a "yahoo" address in the "from" field,
>> is it the responsibilty of the Yahoo server to deliver the mail?
>
> No, it is not.
> The mail will be delivered to the "TO:" address by your SMTP server.
>
> re:
>> do I really need to set up the smart host settings?
>
> You don't have to use a smart host, although sometimes it's better to
> use one.
> Not all the time, though.
>
> re:
>>I read somewhere that the local SMTP server sends the mail
>> to the relay server which will send the email to the recipient.
>
> Only if you use an external SMPT server.
> If you use your own smtp server, *it* will send the mail.
>
> The thing is that you must configure your smtp server so it:
>
> 1. can be found by the .Net Framework
> 2. allows mail relay only from certain IPs or machines.
> Otherwise, anyubody can use *your* smtp server to send *their* mail.
> Spammers would love it if you opened your smtp server so the could
> send their spam.
>
> Have you set the "Connection control" and "Relay Restrictions" ?
> ( in the "Access" tab...after opening the smtp server's properties in
> the IIS Manager ).
>
> This is extremely important.
>
> They should be *both* set to your IP address.
>
> Also, in the "Delivery" tab, in the "Advanced" button,
> you can, optionally, set the domain name, if you have one.
>
> Then, in your code, assign your machine name or domain name to the
> smtp client :
>
> For ASP.NET 2.0 :
> Dim client As New SmtpClient("yourmachinename")
> client.Send(mail)
>
> For ASP.NET 1.1 :
> System.Web.Mail.SmtpMail.SmtpServer = "your machine name or your
> domain name"
> System.Web.Mail.SmtpMail.Send(mail)
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en español : http://asp.net.do/foros/
> ===================================
> "supz" <su****@yahoo.com> wrote in message
> news:11**********************@u72g2000cwu.googlegr oups.com...
>> Thanks for your prompt replies. This might be a stupid quuestion, but
>> do I really need to set up the smart host settings? I read somewhere
>> that the local SMTP server sends the mail to the relay server which
>> will send the email to the recipient. If I send using a "yahoo"
>> address
>> in the "from" field, is it the responsibilty of the Yahoo server to
>> deliver the mail?
>>
>
>



Feb 28 '06 #14
hi all,

i am getting the same problem but in windows application (vb.net). whenever
i try to send email from em***@mydomain.com to so*********@mydomain.com it
works fine but if i change address TO field with valid yahoo / hotmail the
message going in the queue folder.

i am planning to develop an email sending application that sends GCC
investment oppertunies / GCC Market Review / Other Market Results to our
90,000 subscribers.
any suggestion would be greatly appricated :)

"supz" wrote:
Hi,

I use the standard code given below to send an email from an ASP.NET
web form. The code executes fine but no Email is sent. All emails get
queued in the Inetpub mail queue.

I'm using my local default SMTP Server and my from address is a valid
Yahoo/Hotmail address. I have configures the local SMTP Server to allow
the IP Address 127.0.0.1.

Could this be because yahoo/hotmail servers need authentication?

Here's the code I use.

private void SendSimpleMail()
{

MailMessage objEmail = New MailMessage();
objEmail.From = "va******@yahoo.com";
objEmail.To = "an**************@hotmail.com";
objEmail.Subject = "Test Mail";
objEmail.Body = "Test Mail - Body";
SmtpMail.SmtpServer = "127.0.0.1";
SmtpMail.Send(objEmail);

}
Any idea what could be wrong or what I need to do to send a simple
email from ASP.NET? Any help would be appreaciated.

Regards,
supz

Mar 1 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jason | last post by:
Hi not sure if this is the write place, but i really need some help with this...! I have a piece of code that sends email using the SmtpMail class, in an ASP.NET web application, with...
2
by: Leszek | last post by:
Hello, I have created a simple code to send emails using the MailMessage class and the SmtpMail.Send() method: MailMessage mail = new MailMessage(); mail.From = echidna@somewhere.com; //...
6
by: Cameron Eckman | last post by:
I get various errors when I try to use email on the machine I have. XP professional. It works fine on another machine with NT 2000 server. Below is the code: 'BEGIN CODE Dim oMail As New...
5
by: ElanKathir | last post by:
Hi ! I wrote one code for Send the E-mail, But that code have some problem , So please help me Here i paste my code and Error: Error: Server Error in '/Elan_Sample' Application. ...
2
by: Edward | last post by:
Hello, everybody, I tried to send Email out using ASP.NET, but failed, here is the code of sending: -------------------------------------------------------------------------------- Try...
3
by: Jens | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object†when I call SmtpMail.Send. This only happens when I send...
2
by: Wayne Wengert | last post by:
I have an aspx page in which I step through emails from a SQL Server table and snd each a custom email message. The emails in that table are all valid formats. When I run the page I immediately get...
19
by: zdrakec | last post by:
Hello all: Using an "Imports System.Web.Mail" clause at the head of my module, and after executing the following code: Dim msg As New MailMessage msg.From = sender msg.To = recipient...
1
borisding
by: borisding | last post by:
Hi! there, Recently, my client's website, which is coded in ASP Classic has problem in sending email. The script is using Jmail for the email part. Here is the error message: "jmail.SMTPMail...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.