[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 753
  • Last Modified:

using CDO.Message object in php

I am an ASP programmer and needing to write an application in PHP. Is it possible to use the CDO.Message object within the PHP language?

If so, could someone provide a snippet of code on how to do it? I need to create a web form that sends an e-mail to the admin when a comment has been filled out on their page.

Thanks so much!
0
samic400
Asked:
samic400
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
Hello samic400,

I'm not sure. But you can embed a VBScript in your page and use CDO.Message with VBScript.

Fast googled : http://www.asp-php.net/ressources/codes/VBScript-Envoi+de+MAIL+via+CDO.aspx

Regards.
0
 
Ray PaseurCommented:
The PHP "form-to-email" script has been done before, as you may imagine.  Here is a sample.  

See line 16 and 17 where you would put the admin's email address.

Please post back with any questions, and best wishes for the New year, ~Ray
<?php // RAY_form_to_mail.php
error_reporting(E_ALL);

// SEND MAIL FROM A FORM

// A FUNCTION TO CLEAN UP THE DATA - AVOID BECOMING AN OPEN-RELAY FOR SPAM
function clean_string($str)
{
    $str = stripslashes($str);
    $str = trim(ereg_replace(" +", " ", $str));
    $str = ereg_replace('[^ a-zA-Z0-9&+:?_\.\-]', '', $str);
    return $str;
}

// REQUIRED VALUES ARE PREPOPULATED - CHANGE THESE FOR YOUR TEST
$to    = "You@Your.org";
$from  = "NoReply@Your.org";
$subj  = "Contact Form";

// IF THE DATA HAS BEEN POSTED
if (!empty($_POST['email']))
{

// CLEAN UP THE POTENTIALLY BAD AND DANGEROUS DATA
    $email      = clean_string($_POST["email"]);
    $name       = clean_string($_POST["name"]);
    $telephone  = clean_string($_POST["telephone"]);

// CONSTRUCT THE MESSAGE
    $content    = '';
    $content   .= "You have a New Query From $name \n\n";
    $content   .= "Tel No: $telephone\n";
    $content   .= "Email: $email\n";

// SEND MAIL
    if (!mail( $to, $subj, $content, "From: $from\r\n"))
    {
        die("MAIL FAILED FOR $to");
    } else
    {
        die("MAIL SUCCEEDED FOR $to");
    }
} // END OF PHP - PUT UP THE FORM
?>
<form method="post">
<br/>Email: <input name="email" />
<br/>Phone: <input name="telephone" />
<br/>Name:  <input name="name" />
<br/><input type="submit" />
</form>

Open in new window

0
 
samic400Author Commented:
Thanks so much for your help!
0
 
Ray PaseurCommented:
Thanks for the points - maybe you can help me with ASP some day!  Best, ~Ray
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now