Sending emails through Asp.net

  • Thread starter Thread starter mark
  • Start date Start date
M

mark

I need to send order confirmation emails through my asp.net
storefront. With my Asp 3.0 sites I use cdonts with no issues. I've
researched the system.web.mail asp.net way and haven't got it to work.
It boils down to the online smtp server declaration. I say a
solution to active relay on the mail server but in the next sentence
it said doing this may open your server up to spam relays. Not what I
want to do. I've tried using cdonts with asp.net and actually was
surprised to see it work offline while I was testing on my machine.
When I tried it online I got an exception. Any thoughts on this? I
even tried to use server.transfer("old asp3.0 email script") to
trigger the email but also received an exception.
 
Mark,

Although I'm no expert on this subject I don't see how using the built in
System.Web.Mail class could ever "open up for relaying spam". The mail class
and your SMTP server has absolutely nothing to do with eachother other than
an occasional handshake whenever you are trying to send a mail.

MailMessage m = new MailMessage();
m.Subject = "Hello world";
m.From= "(e-mail address removed)";
m.To = "(e-mail address removed)";
m.Body = "This is just a test";
SmtpMail.SmtpServer = "localhost"; //or whatever SMTP server that normally
allows you to relay (could be your ISPs)
SmtpMail.Send(m);

What happens here is simply that the Send method of SmtpMail class connects
to the specified SMTP server and sends the mail!

This is a transcript of what's going on when sending a mail:
HELO localhost //Function handshakes with SMTP-server
250 locahost Hello localhost // Server responds
mail from: (e-mail address removed) //function sends sender email
250 Sender OK //Server accepts
rcpt to: (e-mail address removed) //function sends recipients email
250 Recipient OK. Will forward //Server accepts (OR denies!!)
data //Starting actual body and subject
subject: "Hello world"

This is just a test
. //the dot tells the smtp server that message is completed
250 Message accepted for delivery //Server accepts and sends!

I don't see any reasons why all of a sudden your SMTP server should be open
for spammers. This can only be changed by a setting inside your Mailserver,
and not by .Net itself unless you are able to code directly to your mail
server!

If anyone else has another (or better) explanation, please disregard this
one! ;)

Hope that it helps,

Thomas Regin.
 
Back
Top