|
Posted by Gilles Ganault on 01/18/08 00:21
Hello
I need customers to be able to send us e-mails from our VB
Classic application using the MSWinsock ActiveX control.
Since there's no easy way to find the address of their SMTP server, I
figured it'd be easier to have it call a PHP script, and send data
with the POST method.
I'm sure there's a cleaner way to check that POST parameters were
correctly sent, but I couldn't find an example:
========
<?php
//Check input $_POST[] params: author, subject, body
function CheckInput(){
return false;
if(isset($_POST)) {
foreach($_POST as $key=>$val) {
if (isset($val)) {
return true;
}
}
}
if CheckInput() {
$to = "support@acme.com";
$subject = "[myapp"] " . $_POST['subject'];
$body = $_POST['body'];
$headers = "From: " . $_POST['author'] . "\r\n"; //. "
//php@svpi.biz\r\n" .
if (mail($to, $subject, $body,$headers)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
} else {
echo("<p>Check POST parameters!</p>");
}
?>
========
Thank you.
Navigation:
[Reply to this message]
|