CREATE OR REPLACE FUNCTION phpmail(text,text,text,text) RETURNS integer AS ' # Argument list $email_address = $arg0; $email_from = $arg1; $subject = $arg2; $body = $arg3;
# # ..Typically, you would validate arguments here
# Build email headers $headers = "From: $email_from\r\n"; $headers .= "Reply-To: $email_from\r\n"; $headers .= "X-Mailer: plPHP";
# Send email if (mail($email_address, $subject, $body, $headers)) { return 1; } else { return 0; }
' LANGUAGE 'plphp';
#############################################
# Usage
#############################################
plphp_test=# SELECT phpmail('rrussell@xxxxxxxxxxxxxxxxx', 'webmaster@xxxxxxxxxxxxxxxx', 'Subject Line', 'This is the email body\n\nMore body. Testing email. Test!\n\n\n-Robby') as email;
INFO: ret_val(long): 1
-------
1
(1 row)
############################################# # Output ############################################# webmaster@xxxxxxxxxxxxxxxx typed this on 01/30/2004 08:34 AM: > This is a body > > More body. Testing email. Test! > > > -Robby
Feel free to join the plPHP mailing list as well. http://mail.commandprompt.com/mailman/listinfo/plphp
Cheers,
Robby Russell
-- #------------------------------------------------------- # Robby Russell, | Sr. Administrator / Lead Programmer # Command Prompt, Inc. | http://www.commandprompt.com # rrussell@xxxxxxxxxxxxxxxxx | Telephone: (503) 667.4564 #-------------------------------------------------------
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php