|
Script to send mail using
ASP
All outgoing mail sent from DotNetted customer sites
must be routed through our mailserver using authentication
to provide additional security and guard against abuse
- for this reason the SMTP service is not installed
on our web servers so CDONTS and CDOSYS are not available
to your .asp scripts for sending mail.
Instead we provide the very popular and
reliable AspEmail component from Persits
to enable you to send mail from your ASP
scripts. AspEmail is totally reliable, offers
many additional features over CDO and typically
uses a lot less code to do the same job.
Full information on AspEmail as well as
many sample scripts and the full object
reference can be found on the authors web
site : www.AspEmail.com
Simple ASP Script to send
mail using AspEmail
The following is a very basic script to
send a mail from an .asp page (we will build
on this mail in the next
scripting example to retrieve and e-mail
information from a form). Note that lines
starting ' are explanatory only - these
lines are not parsed by the server.
<%
' First Step is
to create the AspEmail message object
Set Mail = Server.CreateObject("Persits.MailSender")
' Set the from address
- replace
value within the quotes with your own
Mail.From = "me@mysite.co.uk"
' Add the e-mail
recipient address - again replace value
within the quotes with your own
Mail.AddAddress "you@yoursite.co.uk"
' Set the subject
for the e-mail
Mail.Subject = "Test mail via AspEmail"
' Create the body
text for the e-mail
Mail.Body = "This mail was sent via
AspEmail"
' The mail server
requires that we authenticate so supply
username and password
Mail.Username = "me@mysite.co.uk"
Mail.Password = "password"
' The e-mail is
now ready to go, we just need to specify
the server and send
Mail.Host = "smtp.dotnetted.co.uk"
Mail.Send
' Mail is sent -
tidy up and delete the AspEmail message
object
Set Mail = Nothing
%>
That's it - you just need to substitute
your own values where required and you should
be able to copy this script to your account
and send your first e-mail.
Note that as we use authentication the
'Mail.From' e-mail address must be a live
user on our mailserver (and should match
the address used for the 'Mail.Username').
Notes
This is a very basic script, for more information and
the additional options available within AspEmail please
visit the authors web site : www.aspemail.com
|