logonutility Posted March 13, 2021 Share Posted March 13, 2021 I am trying to integrate php mail script on my website Logon Utility but getting error such as : <?php require_once "recaptchalib.php"; // your secret key $secret = "xxxxxxxxxxxxxx"; // empty response $response = null; // check secret key $reCaptcha = new ReCaptcha($secret); if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"] ); } if ($response != null && $response->success) { require_once "Mail.php"; $pcount=0; $gcount=0; $file=""; $from=$_POST['email']; $from2='info@yourdomain.com'; $name=$_REQUEST['name']; $from = "".$name." <".$_POST['email'].">"; $to = "info@yourdomain.com"; $subject = "Mail from Logon Utility"; while (list($key,$val)=each($_POST)) { if($key!='submit' && $key!='g-recaptcha-response') { $pstr = $pstr."$key : $val \n "; ++$pcount; } } while (list($key,$val)=each($_GET)) { if($key!='submit' && $key!='g-recaptcha-response') { $gstr = $gstr."$key : $val \n "; ++$gcount; } } if ($pcount > $gcount) { $message_body=$pstr; } else { $message_body=$gstr; } $host = "ssl://secure.emailsrvr.com"; $port = "465"; $username = "info@yourdomain.com"; $password = "xxxxxxx"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $headers2 = array ('From' =>$from2 , 'To' => $from, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $message_body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { //echo("<p>Message successfully sent!</p>"); header( "Location: thankyou.html"); } } else { if(isset($_SERVER['HTTP_REFERER'])) { $ref= $_SERVER['HTTP_REFERER']; } header("Location: ".$ref.""); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/312290-smtp-mail-function/ Share on other sites More sharing options...
Barand Posted March 13, 2021 Share Posted March 13, 2021 35 minutes ago, logonutility said: ... but getting error such as : Such as what? Quote Link to comment https://forums.phpfreaks.com/topic/312290-smtp-mail-function/#findComment-1585059 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.