Friday, January 2, 2009

server-side send email scripts (simplest and working)

PHP
$to = "recipient@example.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
echo("Message successfully sent!");}
else {
echo("Message delivery failed...");}

ASP
Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "test"
objMessage.From = "emailaddr@domains.ext"
objMessage.To = request.Form("emailadd")
objMessage.TextBody = "Blah"
objMessage.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
objMessage.Configuration.Fields.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
* mail server should be running and functioning
* mail server's mail service configuration should be considered

No comments: