vbcoach Posted March 26, 2010 Share Posted March 26, 2010 My ISP / Webhost says mail can be sent from their server using CDO. However the code they gave me is written in ASP and I use PHP for our site. Can CDO be used to send mail via PHP? Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/ Share on other sites More sharing options...
trq Posted March 27, 2010 Share Posted March 27, 2010 Can CDO be used to send mail via PHP? Yes, via com. Ive never heard of it being used though. If your host actually supports PHP they should have configured PHP's mail function to work. Sounds like your on windows hosting anyway, I would be very tempted to change hosts. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1032570 Share on other sites More sharing options...
jonsjava Posted March 27, 2010 Share Posted March 27, 2010 you *could* use gmail as your mailer for your php scripts (read how here) Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1032576 Share on other sites More sharing options...
atrum Posted March 27, 2010 Share Posted March 27, 2010 Here have a fully functional example <HTML> <HEAD><TITLE></TITLE></HEAD> <BODY> <table> <tr> <td valign="top"> <fieldset> <legend> <a href="php-smtp.php">PHP</a> </legend> <br> <table> <tr> <form method="POST" action=""> <td valign="top"> <fieldset> <legend> Addresses </legend> From:<br> <input id="fromfield" name="fromfield" type="text" value="From address" /><br><br> To:<br> <input id="tofield" name="tofield" type="text" value="To Address" /><br><br> CC:<br> <input id="ccfield" name="ccfield" type="text" value="" /><br><br> BCC:<br> <input id="bccfield" name="bccfield" type="text" value="" /><br><br> </fieldset> </td> <td valign="top"> <fieldset> <legend> Message </legend> Subject:<br> <input id="subjectfield" name="subjectfield" type="text" value="Test Message Subject" /><br><br> Body:<br> <textarea rows="3" name="bodyfield" cols="15">Test message body.</textarea><br><br> </fieldset> </td><td valign="top"> <fieldset> <legend> Server details </legend> SMTP Server:<br> <input id="serverfield" name="serverfield" type="text" value="mail-fwd" /><br><br> Port Number:<br> <input id="portfield" name="portfield" type="text" value="25" /><br><br> SMTP Auth<br> <fieldset class="radio"> <legend> <input id="smtpauthnofield" name="smtpauthfield" type="radio" checked value="0" /> No </legend> </fieldset> <fieldset class="radio"> <legend> <input id="smtpauthyesfield" name="smtpauthfield" type="radio" value="1" /> Yes </legend> User ID:<br> <input id="useridfield" name="useridfield" type="text" value="User ID" /><br><br> Password:<br> <input id="passwordfield" name="passwordfield" type="text" value="Password" /><br><br> </fieldset><br><br><br> <INPUT TYPE="SUBMIT" VALUE="SUBMIT" name="send_mail"> </fieldset> </td> </form> </tr> </table> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="asp-smtp.asp">ASP</a> </legend> <br> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="vb-net-smtp.aspx">VB .NET</a> </legend> <br> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="c-net-smtp.aspx">C# .NET</a> </legend> <br> </fieldset> </td> </table> <hr> <? $fromWho=$_POST['fromfield']; $toWho=$_POST['tofield']; $ccWho=$_POST['ccfield']; $bccWho=$_POST['bccfield']; $Subject=$_POST['subjectfield']; $Body=$_POST['bodyfield']; $MailServer=$_POST['serverfield']; $Port=$_POST['portfield']; $SMTPauth=$_POST['smtpauthfield']; $UserID=$_POST['useridfield']; $Password=$_POST['passwordfield']; if ($_POST['send_mail']=="SUBMIT") { $message = new COM('CDO.Message'); $messageCon= new COM('CDO.Configuration') ; try { $message->From = $fromWho; $message->To = $toWho; $message->CC = $ccWho; $message->BCC = $bccWho; $message->Subject = $Subject; $message->HTMLBody = $Body; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpserver'] = "$MailServer"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpserverport'] = "$Port"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpauthenticate'] = "$SMTPauth"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendusername'] = "$UserID"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendpassword'] = "$Password"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendusing'] = 2 ; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout'] = 60 ; $messageCon->Fields->Update(); $message->Configuration = $messageCon; $message->Send() ; } catch (com_exception $e) { print "<hr>\n\n"; print $e . "\n"; } if ($e === NULL) print "Message sent successfull.\n\n"; else print "<hr>\n\n"; ; } ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1032589 Share on other sites More sharing options...
vbcoach Posted March 28, 2010 Author Share Posted March 28, 2010 Hey great example, atrum. Much appreciated. However I probably should have been more clear. I have a registration form that a user fills out. When complete, this registration form is processed and the information is entered into the database and a "receipt" page is displayed with the users inputted information. What I am looking for is a way to (also) send that information to the user email address via email using PHP. My hosting provider says this can be done with CDO. (The PHP mail() function is apparently disabled for security purposes) The hosting provider sent me an example, but their example is a vbscript. Not sure if that helps me in PHP. I need to basically take the whole web page and dump it into an email to the end user. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033018 Share on other sites More sharing options...
vbcoach Posted March 28, 2010 Author Share Posted March 28, 2010 This is what the hosting service provided me as an example. I could use some help with this. Dim objMail Set objMail = Server.CreateObject("CDONTS.NewMail") objMail.From = address_email objMail.Subject = "xxx" objMail.To = "[email protected]" objMail.Body = msg objMail.Send set objMail = nothing address_email is a variable from your form data, the person filling out the form. objMailTo would be you. It can even handle the additional objMail.Cc variable. You can google the code for further syntax. Msg is a variable you create for format the email message you want to send IN the email. Here is an example. Dim msg msg = "THE FOLLOWING PERSON HAS REQUESTED TO BE ADDED TO YOUR MAILING LIST:" & chr(10) & chr(10) msg = msg & "EMAIL: " & address_email & chr(10) & chr(10) & chr(10) msg = msg & "--------------------------------" & chr(10) msg = msg & "http://www.domain.com" & chr(10) msg = msg & "--------------------------------" & chr(10) Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033040 Share on other sites More sharing options...
trq Posted March 28, 2010 Share Posted March 28, 2010 So what part of atrum's example can you not understand? Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033198 Share on other sites More sharing options...
vbcoach Posted March 28, 2010 Author Share Posted March 28, 2010 Don't understand any of it. The code antrum gave me doesn't work. I uploaded the code to my web site for a test and get an unexpected { error. Also, antrum's code, from what I can gather is useful for a contact form. I do not see how I can take existing webpage and email it using what he wrote. So until I can get the code to work and see exactly what it is doing, I am still at square one unfortunately. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033211 Share on other sites More sharing options...
trq Posted March 28, 2010 Share Posted March 28, 2010 antrum's code has all the pieces you should need to get your requirement completed. Short of writing the page for you, I'm not sure what else we can do. Do you want to post what you have and we'll go from here? Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033271 Share on other sites More sharing options...
vbcoach Posted March 29, 2010 Author Share Posted March 29, 2010 Ok, let me start over. Again, a registration page for a sports website (http://www.baltimorebeach.com/registration/teamregistration2010.php) is used for team captains to register their team. When complete, it goes to a processing page when the input is dumped into the database and a receipt page is displayed on the screen, which the captain is instructed to print out for his records as it contains all of his team's information, including his username and password to access the site (which of course the 'male' captains never do). We get dozens of emails a week asking for UN and PW requests because they were not sent a confirmation email. Duh. We haven't created one. yes I could create a reset password page, but it would be so much easier just to send the team captains a copy of their information via when registering. My hope is to take this "information" page and send it to the team captain via the email address he entered for the captain. My code is this: <?php if($_POST) { foreach ($_POST as $k=>$v) { $t = stripslashes($v); $t = str_replace("'",'′',$t); $vals[$k] = $t; } //Connect to Database $conn = mssql_connect ("localhost", "********", "********") or die ('I cannot connect to the database because: '); mssql_select_db("baltimorebeach"); $teamname = "SELECT t_id FROM team WHERE league = '$vals[league]' AND teamname='$vals[teamname]'"; $tres = mssql_query($teamname); if(mssql_rows_affected($conn) != 0) { $lsql = "SELECT * FROM league WHERE active = 1 AND [session] = 'Spring' ORDER BY l_id"; $lres = mssql_query($lsql,$conn); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>2010 Team Registration Complete</title> <link rel="stylesheet" href="dh2styles.css" type="text/css"> <script language="javascript"> function isEmail(str) { // are regular expressions supported? var supported = 0; if (window.RegExp) { var tempStr = "a"; var tempReg = new RegExp(tempStr); if (tempReg.test(tempStr)) supported = 1; } if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)"); var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); return (!r1.test(str) && r2.test(str)); } function validate (theForm) { var errStr = ""; if(theForm.teamname.value == '') { errStr += "Team name not entered\n"; } if(theForm.league.value == -1) { errStr += "Please select a league in which to participate\n"; } if(theForm.shirtsize.value == -1) { errStr += "Please select a t-shirt color\n"; } if(!isEmail(theForm.cpt_email.value)) { errStr += "Please enter a valid e-mail address\n"; } if(theForm.cpt_first.value=='' || theForm.cpt_last.value=='') { errStr += "Captain's name incomplete\n"; } if(theForm.cpt_address.value=='' || theForm.cpt_city.value==''|| theForm.cpt_state.value== -1 || theForm.cpt_zip.value=='') { errStr += "Captain's address incomplete\n"; } if(theForm.cpt_shirtsize.value == -1) { errStr += "Please select a shirt size for the captain"; } if(errStr != "") { alert("The following problems have occurred\n\n"+errStr); return false; } return true; } </script> <style type="text/css"> <!-- .style8 { color: #FF0000; font-size: 18px; } .style9 {color: #000000} a:link { color: #000000; } a:visited { color: #000000; } --> </style> </head> <body> <h4 align="center"> <img src="http://www.baltimorebeach.com/images/oops3.gif" alt="Oops! Team Name Already In Use" /> </h4> <h4 align="center" class="style5"><span class="style4">Team name </span><strong><em>"<span class="style7 style8"><?= $vals['teamname'] ?></span>"</em> already taken for this league! Please selecet a different name</strong>. </h4> <h4 align="center"><p align="center" class="style9">Please press <a href="javascript:history.back()">Back</a> on your browser and choose a different team name </p> </h4> </body> </html> <?php mssql_close($conn); exit; }//if team name already exists //League Info $leagueId = $vals['league']; $leagueRes = mssql_query("SELECT * FROM league WHERE l_id = $leagueId",$conn); $lSize = mssql_fetch_assoc($leagueRes); //Create the captain $ln = strtolower(substr($vals['cpt_first'],0,1).str_replace("'","",$vals['cpt_last'])); $loginSQL = "SELECT COUNT(*) FROM captain WHERE username LIKE '$ln%'"; $lres = mssql_query($loginSQL,$conn); $count = mssql_fetch_row($lres); //login is first initial + last name $login = strtolower(substr($vals['cpt_first'],0,1).str_replace("'","",$vals['cpt_last'])).substr($lSize['type'],0,1).$lSize['size'].$lSize['division']; if($count[0] > 0) { $login = strtolower(substr($vals['cpt_first'],0,1).str_replace("'","",$vals['cpt_last']).$count[0].substr($lSize['type'],0,1).$lSize['size'].$lSize['division']); } $password = strtolower(substr($vals['cpt_first'],0,1).substr($vals['cpt_last'],0,1).substr($vals['cpt_phone'],-4)); $cpt_sql = "INSERT INTO captain (username,password,firstname,lastname,address,city,state,zip,email,phone,shirtsize,returningteam,rteamname) VALUES ('$login','$password','$vals[cpt_first]','$vals[cpt_last]','$vals[cpt_address]','$vals[cpt_city]','$vals[cpt_state]','$vals[cpt_zip]','$vals[cpt_email]','$vals[cpt_phone]','$vals[cpt_shirtsize]','$vals[returningteam]','$vals[rteamname]')"; //run captain query $query = mssql_query($cpt_sql,$conn); //Find the captains id # for the team information $query = mssql_query("SELECT c_id FROM captain ORDER BY c_id DESC;",$conn); $qRes = mssql_fetch_assoc($query); $cptId = $qRes['c_id']; //$cptId = 1; //---------- $getip = $_SERVER['REMOTE_ADDR']; //Create the team $team_sql = "INSERT INTO team (teamname,shirtcolor,league,captain,venue,ip) VALUES ('$vals[teamname]','$vals[shirtcolor]','$leagueId','$cptId','$vals[venue]','$getip')"; //echo $team_sql; //run team query $query = mssql_query($team_sql,$conn); //find team id for players $query1 = mssql_query("SELECT t_id FROM team ORDER BY t_id DESC;",$conn); $qRes = mssql_fetch_assoc($query1); $teamId = $qRes['t_id']; //------------------ //build players /* loop through all ten possible players listed and check to see if the name field has at least 2 characters. If it does then we will grab the other 3 bits of information and add the player to the database. */ $players = ''; $pCount = 1; $members = $leagueId == 31 ? 6:11; for($i =1; $i <= $members; $i++) { if(strlen($vals['player'.$i.'_name']) > 2) { $pName = $vals['player'.$i.'_name']; $pEmail = $vals['player'.$i.'_email']; $ppShirt = $vals['player'.$i.'_shirt']; $pCount ++; $p_sql = "INSERT INTO player (name,email,team,pshirt) VALUES ('$pName','$pEmail','$teamId','$ppShirt')"; $query = mssql_query($p_sql,$conn); $players .= "$pName - $ppShirt <br />\n"; } } //------------- mssql_close($conn); //calculate Fees $size = $lSize['size']; switch($size) { case 2: $base = 150; $size = 3; break; case 4: $base = 330; $size = 6; break; case 6: $base = 550; $size = 10; break; default: die ("invalid league size"); }; $earlyTeam = $base; { $e_each = $earlyTeam / $pCount; $lateTeam = $earlyTeam * 1.10; $l_each = $lateTeam / $pCount; } //POST everything else - time to display more variables echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>2010 Summer Session Team Registration Confirmation</title> <link rel="stylesheet" href="jahstyles.css" type="text/css"> </head> <body> '; echo " <div id=\"banner\"> <img border=\"0\" src=\"bbeachlogo.jpg\"> <h3>Team $vals[teamname] Registration for \"Spring\" Leagues 2010!</h3> <p <font face=\"Comic Sans MS\">Thank you for registering with Baltimore Beach, please <strong><a href=\"javascript:window.print()\">PRINT</a></strong> this page for your records.<br> <strong>Registration is not considered complete until team fees have been paid.</strong><br> Please send one check for team fees, as captain, this responsibility falls to you.<br><br> To view all other teams that have registered in your league <a href=\"http://www.baltimorebeach.com/spring2010leagueinfo.php?l=$lSize[l_id]\">click here</a> <h2><b><u>Team Captain Info:</u></b></h2> <strong>Name</strong>: $vals[cpt_first] $vals[cpt_last]<br> <strong>Address</strong>: $vals[cpt_address] $vals[cpt_city], $vals[cpt_state] $vals[cpt_zip]<br> <strong>Email</strong>: $vals[cpt_email]<br> <strong>Shirt</strong>: $vals[cpt_shirtsize]<br> <strong>Login</strong>: $login<br> <strong>Password</strong>: $password<br> Captain's web page is: <a href=\"http://www.baltimorebeach.com/cp\">http://www.baltimorebeach.com/cp</a> <h2><b><u>Team Info:</u></b></h2> <strong>BBV League</strong>: Spring $lSize[night] $lSize[type] $lSize[size] $lSize[division]<br> <strong>Team Name</strong>: $vals[teamname]<br> <strong>T-Shirt Color</strong>: $vals[shirtcolor]<br> <strong>No. of Players</strong>: $pCount<br> <strong>Team Fees Due</strong>: \$$earlyTeam<br> </p> <p> <h2><b><u>Players / Shirt Sizes:</u></b></h2> $players </p> <p> <p><span class=\"style99\">Make (one) team registration check payable to</span><strong>:</strong> <span class=\"style34\">Baltimore Beach</span> <br /> <span class=\"style98\">*Please enter team name, league night & division on memo line</span></p> <p align=\"left\"><span class=\"style99\">Send to</span><strong>:</strong> <span class=\"style33\">Baltimore Beach<br /> 1317 S. Hanover Street <br /> Baltimore, MD 21230</span></p> <p align=\"left\"><span class=\"style33\">*** League payments now accepted via PayPal ***</span><br> <a href=\"http://www.baltimorebeach.com/paypal.htm\" target=\"_self\"><img src=\"http://www.baltimorebeach.com/images/paypal.jpg\" width=\"150\" height=\"52\" hspace=\"61\" border=\"0\" longdesc=\"http://www.baltimorebeach.com/images/paypal.jpg\"></a><br> <img src=\"http://www.baltimorebeach.com/images/paypal2.jpg\" width=\"148\" height=\"17\" hspace=\"62\" vspace=\"0\" longdesc=\"http://www.baltimorebeach.com/images/paypal2.jpg\"></p> </div> </body> </html> "; } /* */ ?> Please keep in mind that I am not an experienced PHP programmer. I inherited this already-existing project. Thanks in advance for any assistance. My only option for sending email via the hosting provider is using CDONTS (CDO) Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033587 Share on other sites More sharing options...
MatthewJ Posted March 29, 2010 Share Posted March 29, 2010 You don't need to send the "whole page", only the data that is important to them. So using the example you were provided, instead of displaying their entered data, wrap it up in an email and send it off just like you would a contact form. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033603 Share on other sites More sharing options...
vbcoach Posted March 30, 2010 Author Share Posted March 30, 2010 Matthew, that's the problem. I do not know how to do that with CDONTS! No idea whatsoever. That is why I am here. Really needing some assistance here. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1033907 Share on other sites More sharing options...
vbcoach Posted March 31, 2010 Author Share Posted March 31, 2010 Hello? Anyone? Buehler? Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1034876 Share on other sites More sharing options...
trq Posted March 31, 2010 Share Posted March 31, 2010 Matthew, that's the problem. I do not know how to do that with CDONTS! No idea whatsoever. The formatting of the email has nothing to do with cdonts. Then there was a perfectly good example of how to send mail with cdonts posted by atrum. maybe you should at least make an attempt. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1034918 Share on other sites More sharing options...
vbcoach Posted April 5, 2010 Author Share Posted April 5, 2010 I have spent nearly a week "trying" this code of Antrum's. Once again it still does not work. If it worked, then I might be able to adapt it to my needs. However I do not understand either CDONTS or Antrum's code or what is wrong. There is an error in the "try" statement. Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1036989 Share on other sites More sharing options...
thriftyjunkman Posted February 19, 2013 Share Posted February 19, 2013 Here have a fully functional example <HTML> <HEAD><TITLE></TITLE></HEAD> <BODY> <table> <tr> <td valign="top"> <fieldset> <legend> <a href="php-smtp.php">PHP</a> </legend> <br> <table> <tr> <form method="POST" action=""> <td valign="top"> <fieldset> <legend> Addresses </legend> From:<br> <input id="fromfield" name="fromfield" type="text" value="From address" /><br><br> To:<br> <input id="tofield" name="tofield" type="text" value="To Address" /><br><br> CC:<br> <input id="ccfield" name="ccfield" type="text" value="" /><br><br> BCC:<br> <input id="bccfield" name="bccfield" type="text" value="" /><br><br> </fieldset> </td> <td valign="top"> <fieldset> <legend> Message </legend> Subject:<br> <input id="subjectfield" name="subjectfield" type="text" value="Test Message Subject" /><br><br> Body:<br> <textarea rows="3" name="bodyfield" cols="15">Test message body.</textarea><br><br> </fieldset> </td><td valign="top"> <fieldset> <legend> Server details </legend> SMTP Server:<br> <input id="serverfield" name="serverfield" type="text" value="mail-fwd" /><br><br> Port Number:<br> <input id="portfield" name="portfield" type="text" value="25" /><br><br> SMTP Auth<br> <fieldset class="radio"> <legend> <input id="smtpauthnofield" name="smtpauthfield" type="radio" checked value="0" /> No </legend> </fieldset> <fieldset class="radio"> <legend> <input id="smtpauthyesfield" name="smtpauthfield" type="radio" value="1" /> Yes </legend> User ID:<br> <input id="useridfield" name="useridfield" type="text" value="User ID" /><br><br> Password:<br> <input id="passwordfield" name="passwordfield" type="text" value="Password" /><br><br> </fieldset><br><br><br> <INPUT TYPE="SUBMIT" VALUE="SUBMIT" name="send_mail"> </fieldset> </td> </form> </tr> </table> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="asp-smtp.asp">ASP</a> </legend> <br> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="vb-net-smtp.aspx">VB .NET</a> </legend> <br> </fieldset> </td> <td valign="top"> <fieldset> <legend> <a href="c-net-smtp.aspx">C# .NET</a> </legend> <br> </fieldset> </td> </table> <hr> <? $fromWho=$_POST['fromfield']; $toWho=$_POST['tofield']; $ccWho=$_POST['ccfield']; $bccWho=$_POST['bccfield']; $Subject=$_POST['subjectfield']; $Body=$_POST['bodyfield']; $MailServer=$_POST['serverfield']; $Port=$_POST['portfield']; $SMTPauth=$_POST['smtpauthfield']; $UserID=$_POST['useridfield']; $Password=$_POST['passwordfield']; if ($_POST['send_mail']=="SUBMIT") { $message = new COM('CDO.Message'); $messageCon= new COM('CDO.Configuration') ; try { $message->From = $fromWho; $message->To = $toWho; $message->CC = $ccWho; $message->BCC = $bccWho; $message->Subject = $Subject; $message->HTMLBody = $Body; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpserver'] = "$MailServer"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpserverport'] = "$Port"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpauthenticate'] = "$SMTPauth"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendusername'] = "$UserID"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendpassword'] = "$Password"; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/sendusing'] = 2 ; $messageCon->Fields['http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout'] = 60 ; $messageCon->Fields->Update(); $message->Configuration = $messageCon; $message->Send() ; } catch (com_exception $e) { print "<hr>\n\n"; print $e . "\n"; } if ($e === NULL) print "Message sent successfull.\n\n"; else print "<hr>\n\n"; ; } ?> </BODY> </HTML> Hi this example is great I found it worked fine for me, I trawled through pages and pages looking for an example of cdosys used with php this was the only one i could find the rest were all asp. So thanks so much for posting it, any way my question is how would i validate to make sure user fills in all fields, ive tryed a javascript example but couldnt make it work and ive a feeling it because of the way in which we are using cdosys. forgive my ignorance i am a first year degree student so i am fairly new to this but keen to learn, your help would be greatly appreciated Link to comment https://forums.phpfreaks.com/topic/196628-can-cdo-mail-be-used-with-php/#findComment-1413359 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.