farkewie Posted May 30, 2007 Share Posted May 30, 2007 Hi I'm having a crack at writing my own code and am a bit stuck i really a noob. the form is pretty simple basicly jst an image verifcation conatct form that updated the database at the same time. i want to use my smtp server because all my email are going in to the junk mail folder using the mail() function. here is my proccess.php form <?php require_once('Connections/test.php'); ?><?php //register globals $time = date("d/m/Y ", time()); $date = date("d/m/Y H:i:s", time()); $tname=$_REQUEST['tname']; $temail=$_REQUEST['temail']; $yname=$_REQUEST['yname']; $yemail=$_REQUEST['yemail']; $msg=$_REQUEST['msg']; $cat=$_POST['cat']; $site_name = "mysite.com"; $site_email = "[email protected]"; $site_url = "www.site.com"; $verif_box = $_REQUEST["verif_box"]; //clean html $msg = stripslashes($msg); $tname = stripslashes($tname); $temail = stripslashes($temail); $yemail = stripslashes($yemail); $yname = stripslashes($yname); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page @mysql_select_db($database_test) or die( "Unable to select database"); $query = "INSERT INTO name VALUES ('$tname','$temail','$msg','$time','$cat','$yname','$yemail','$date')"; mysql_query($query); mysql_close(); if ($query) { $header = "From: $site_name <$site_email>\n"; $header .= "Reply-To: $site_email\n\n"; $from = "[email protected]"; $to = $temail ; $subject = "my subject"; $message = "text here.,\n\n"; $message .= "$msg\n\n\n\n"; $message .= "-------------------------\n"; $message .= "$site_name\n"; $message .= "$site_url\n"; $host = "mail.me.com"; $username = "user"; $password = "pass"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $message); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } } else { echo "sorry didnt send email"; } // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:".$_SERVER['HTTP_REFERER']."?tname=$tname&temail=$temail&yname=$yname&yemail=$yemail&wrong_code=true"); exit; } //end else //end while ?> Now im getting this error: Fatal error: Class 'Mail' not found in /home/tyspicsc/public_html/posthate/proccess_submit.php on line 67 its kind of a dead end for me, im in unchartered waters. im not sure on where to "define" class Mail ? thanks in advance and any tip on the rest of the code would be appreciated - trying to learn. Link to comment https://forums.phpfreaks.com/topic/53593-mail-using-smtp-server-while-inserting-sql-at-same-time/ Share on other sites More sharing options...
farkewie Posted June 1, 2007 Author Share Posted June 1, 2007 Ok so ive looked at all the walkthroughs and i cant work this out?? can anyone give me a link to something where i can email through my smtp server? when i use the mail() function it goes straight to my junk mail folders and says its fro "[email protected]" i want it to be from "[email protected]" i have set the $from but still says same thing? any ideas of what to0 do would be great. Link to comment https://forums.phpfreaks.com/topic/53593-mail-using-smtp-server-while-inserting-sql-at-same-time/#findComment-266128 Share on other sites More sharing options...
thedarkwinter Posted June 1, 2007 Share Posted June 1, 2007 Hi To be honest i have played with PEAR, but php has its own built in mailer function you can use ini_set() to temporarilly change the default smtp server, and mail to send... <?php $mysmtp = "192.168.1.1"; // or whatever ini_set("SMTP", $mysmtp); mail( $to, $subject, $message, $headers ); ini_restore("STMP"); hope that helps cheers, tdw Link to comment https://forums.phpfreaks.com/topic/53593-mail-using-smtp-server-while-inserting-sql-at-same-time/#findComment-266206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.