ASP.NET


SMTP Authentication to send mail from your script
<% @Page Language="C#" %>
<% @Import Namespace="System.Net.Mail" %>
<%
MailMessage mail = new MailMessage();
mail.To = "FRIEND@FRIENDSDOMAIN.COM";
mail.From = "YOU@YOURDOMAIN.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", "YOU@YOURDOMAIN.COM"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "PASSWORD"); //set your password here

SmtpMail.SmtpServer = "localhost"; //your real server goes here
SmtpMail.Send( mail );

%>

VB .NET:

<% @Page Language="VB" %>
<% @Import Namespace="SystemNET.Mail" %>
<%
Dim mail As New MailMessage()
mail.To = "FRIEND@FRIENDSDOMAIN.COM"
mail.From = "YOU@YOURDOMAIN.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", "YOU@YOURDOMAIN.COM") 'set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "PASSWORD") 'set your password here
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

%>
Tips:
Reference: http://www.systemwebmail.com/faq/3.8.aspx
It is only localhost if the application is sitting on the same server as the IMAP service. If you are connecting externally you would need mail.domain.com .

You would replace localhost with the SMTP server for gmail. Email address and password would be your gmail credentials.