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 = "valid_id@dotnet.itags.org.yahoo.com";
objEmail.To = "another_valid_id@dotnet.itags.org.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"supz" <supz_s@.yahoo.com> wrote in message
news:1141024300.733687.88480@.t39g2000cwt.googlegroups.com...
> Could this be because yahoo/hotmail servers need authentication?
www.systemwebmail.com
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" <supz_s@.yahoo.com> wrote in message
news:1141024300.733687.88480@.t39g2000cwt.googlegroups.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 = "valid_id@.yahoo.com";
> objEmail.To = "another_valid_id@.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
>
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?
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 on
e.
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 thei
r spam.
Have you set the "Connection control" and "Relay Restrictions" ?
( in the "Access" tab...after opening the smtp server's properties in the II
S 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 clie
nt :
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 espaol : http://asp.net.do/foros/
===================================
"supz" <supz_s@.yahoo.com> wrote in message
news:1141041359.202659.164960@.u72g2000cwu.googlegroups.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?
>
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 = "you@.yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenti
cate",
"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" <supz_s@.yahoo.com> wrote in message
news:1141041359.202659.164960@.u72g2000cwu.googlegroups.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?
>
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" <nomailreplies@.nowhere.com> wrote in message
news:O7X3Ns5OGHA.1312@.TK2MSFTNGP09.phx.gbl...
> re:
> No, it is not.
> The mail will be delivered to the "TO:" address by your SMTP server.
> re:
> You don't have to use a smart host, although sometimes it's better to use
> one.
> Not all the time, though.
> re:
> 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 espaol : http://asp.net.do/foros/
> ===================================
> "supz" <supz_s@.yahoo.com> wrote in message
> news:1141041359.202659.164960@.u72g2000cwu.googlegroups.com...
>
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" <supz_s@.yahoo.com> wrote in message
news:1141024300.733687.88480@.t39g2000cwt.googlegroups.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 = "valid_id@.yahoo.com";
> objEmail.To = "another_valid_id@.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
>
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" <supz_s@.yahoo.com> wrote in message
news:1141024300.733687.88480@.t39g2000cwt.googlegroups.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 = "valid_id@.yahoo.com";
> objEmail.To = "another_valid_id@.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
>
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 espaol : http://asp.net.do/foros/
===================================
"KMA" <kma@.schneeberger.ch> wrote in message news:dtv287$6vq$1@.atlas.ip-plus.net...arkred">
> Juan,
> Can you explain this a bit more.
> I've just made a contact page for my site to allow people to write a messa
ge. 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 ho
st. 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 alm
ost identical to what
> you've posted below. (1.1 version).
> Thankyou.
>
> "Juan T. Llibre" <nomailreplies@.nowhere.com> wrote in message
> news:O7X3Ns5OGHA.1312@.TK2MSFTNGP09.phx.gbl...
>
0 comments:
Post a Comment