本文发表在 rolia.net 枫下论坛1. common answer is CGI(perl)
code sample:
open(MAIL, "|/usr/lib/sendmail -oi -t") or die "can't fork sendmail: $!";
print MAIL <<EOF;
From: $0 (your cgi script)
To: hisname\@hishost.com
Subject: mailed form submission
EOF
save_parameters(*MAIL);
close(MAIL)
2. PHP. use PHP SMTP code
Solution
Use PEAR's Mail class:
require 'Mail.php';
$to = 'adam@example.com';
$headers['From'] = 'webmaster@example.com';
$headers['Subject'] = 'New Version of PHP Released!';
$body = 'Go to http://www.php.net and download it today!';
$message =& Mail::factory('mail');
$message->send($to, $headers, $body);
If you can't use PEAR's Mail class, use PHP's built-in mail( ) function:
$to = 'adam@example.com';
$subject = 'New Version of PHP Released!';
$body = 'Go to http://www.php.net and download it today!';
mail($to, $subject, $body);
3. ASP on Windoze NT/2K
If you're using ASP in WinNT or Win2K Server, you have CDONTS component
installed by default (unless you customized your Windows installation.
You could send mail by using CDONTS.NewMail object like this:
<%
set o_mailer = Server.CreateObject("CDONTS.NewMail")
o_mailer.From = "me@mydomain.com"
o_mailer.To = "you@yourdomain.com"
o_mailer.Subject = "Test"
o_mailer.Body = "Hello, how are you" &vbCrLf& "I'm testing send mail
function of CDONTS"
o_mailer.Send
set o_mailer = nothing
%>
You could also use other component like ASPMail to do this. Consult the
component manual on how to do that.
4. .NET solution
Use system.web.mail
http://www.aspnetpro.com/features/2002/09/asp200209kg_f/asp200209kg_f.asp
OK?更多精彩文章及讨论,请光临枫下论坛 rolia.net
code sample:
open(MAIL, "|/usr/lib/sendmail -oi -t") or die "can't fork sendmail: $!";
print MAIL <<EOF;
From: $0 (your cgi script)
To: hisname\@hishost.com
Subject: mailed form submission
EOF
save_parameters(*MAIL);
close(MAIL)
2. PHP. use PHP SMTP code
Solution
Use PEAR's Mail class:
require 'Mail.php';
$to = 'adam@example.com';
$headers['From'] = 'webmaster@example.com';
$headers['Subject'] = 'New Version of PHP Released!';
$body = 'Go to http://www.php.net and download it today!';
$message =& Mail::factory('mail');
$message->send($to, $headers, $body);
If you can't use PEAR's Mail class, use PHP's built-in mail( ) function:
$to = 'adam@example.com';
$subject = 'New Version of PHP Released!';
$body = 'Go to http://www.php.net and download it today!';
mail($to, $subject, $body);
3. ASP on Windoze NT/2K
If you're using ASP in WinNT or Win2K Server, you have CDONTS component
installed by default (unless you customized your Windows installation.
You could send mail by using CDONTS.NewMail object like this:
<%
set o_mailer = Server.CreateObject("CDONTS.NewMail")
o_mailer.From = "me@mydomain.com"
o_mailer.To = "you@yourdomain.com"
o_mailer.Subject = "Test"
o_mailer.Body = "Hello, how are you" &vbCrLf& "I'm testing send mail
function of CDONTS"
o_mailer.Send
set o_mailer = nothing
%>
You could also use other component like ASPMail to do this. Consult the
component manual on how to do that.
4. .NET solution
Use system.web.mail
http://www.aspnetpro.com/features/2002/09/asp200209kg_f/asp200209kg_f.asp
OK?更多精彩文章及讨论,请光临枫下论坛 rolia.net