Wednesday, May 26, 2010

how do i send automated mail form my web application?


 Introduction.
At ISQsolutions it is required that all email messaging have to be authenticated, any attempt to send anonymous email will fail. To send email from your website you will need to configure your scripts to authenticate against your designated SMTP server (usually smtp.yourdomain.com or smtp.websoon.com) with one of your existent email accounts at ISQsolutions mail servers.
Sending emails in ASP.NET 2.0
// using System.Net.Mail;
// using System.Net;

SmtpClient smtpClient = new SmtpClient("smtp.domainHosted.com");

smtpClient.Credentials = new NetworkCredential("user1@domainHosted.com", "passwordHere");

MailMessage message = new MailMessage();

message.From = new MailAddress(user1@domainHosted.com);
message.To.Add(new MailAddress(nick@example.com));
message.To.Add(new MailAddress(ben@example.com));

message.Subject = "This is my subject";
message.Body = "This is the content";

smtpClient.Send(message);


- Sending mail from ASP via CDO object. ( What happened to CDONTS ? )
With the introduction of Windows Server 2003, Microsoft dropped support for CDONTS. Therefore, applications that use CDONTS do not function on Windows Server 2003, furthermore CDONTS does not provide the means to send email via authenticated SMTP.


These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.
References:
Microsoft Windows Server 2003 does not install CDONTS : http://support.microsoft.com/default.aspx?scid=kb;en-us;315197


- Sending mail from ASP with Persits ASPEmail object.
Consult the excellent documentation that Persits have put together at : http://www.aspemail.com/manual.html
Here is a short example:


These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.


- Sending mail from ASP.NET.

Here is a C# version.
// using System.Web.Mail;
MailMessage eMail = new MailMessage();
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "account@domainHosted.com";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";
eMail.To = "someone@yahoo.com"; // Recipients
eMail.From = "somebody@yahoo.com";
eMail.Subject = "This is the subject line";
eMail.Body = "Test Message";
SmtpMail.SmtpServer = "smtp.domainHosted.com";
SmtpMail.Send(eMail);
And a VisualBasic version
Dim eMail = new MailMessage()
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "account@domainHosted.com"
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

eMail.To = "someone@yahoo.com"
eMail.From = "somebody@yahoo.com"
eMail.Subject = "This is the subject line"
eMail.Body = "Test Message"
SmtpMail.SmtpServer = "smtp.domainHosted.com"
SmtpMail.Send(eMail)

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.
- Sending mail from PHP.

This sample uses the Pear Mail package. The package is already in the INCLUDE path.
http://pear.php.net/package/Mail
include_once("Mail.php");
$recipients = 'mail_to@domain.mail';
$headers["From"] = 'mail_from@domain.mail';
$headers["To"] = 'mail_to@domain.mail';
$headers["Subject"] = "Test message";
$body = "TEST MESSAGE!!!";
$params["host"] = 'smtp.domainHosted.com';
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = 'account@domainHosted.com';
$params["password"] = "password";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
echo "Email sent."
?>

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.


- Setting up a Form to Mail script.
To set-up a very easy form to mail script you may download the following script. To configure it follow the instructions inside the formmail.asp file.

No comments:

Post a Comment