Support Desk Language
 
Home Knowledge Base Email HOWTO: Sending email from a web site
Information
Article ID5
Created On9/10/2008
Modified9/10/2008
Share With Others
HOWTO: Sending email from a web site

Sending email from a website can be done using the built-in mailer components in ASP.NET or PHP, or in ASP by using the CDO or ASPEmail components.

Regardless of the method used, the correct SMTP server to use for sending from any of our web servers is "localhost".

Please feel free to use the following sample code to get you started.  These samples are confirmed to work on our servers:

ASP.NET Sample:

<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%
string strTo = "sample@email.com";
string strFrom = "sample@email.com";
string strSubject = "Test Email";
string strBody = "Test Email Body";
SmtpMail.Send(strFrom, strTo, strSubject, strBody);
%>

ASP Sample:

<%
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
objMail.To = "sample@email.com"
objMail.From = "sample@email.com"
objMail.Subject = "Mail Test"
objMail.TextBody = "Mail Test Body"
objMail.Send
Set objMail = nothing
%>

PHP Sample: 

<?php
$to = "sample@email.com";
$from = "sample@email.com";
$subject = "Mail Test";
$body = "Mail Test Body";
ini_set("SMTP","localhost");
ini_set("sendmail_from",$from);
$result = mail($to, $subject, $body, "From: $from");
?>