mysmsmantra Posted December 8, 2020 Share Posted December 8, 2020 (edited) Hi PHP Developers, I am trying to integrate php mail script on my website mysmsmantra but getting error such as : Fatal error: Uncaught Error: Call to undefined method PEAR_Error::send() in /home/website/public_html/mysmsmantra.com/sendmail2.php:99 Stack trace: #0 {main} thrown in /home/website/public_html/mysmsmantra.com/sendmail2.php on line 99 I am using below code to send mail : <?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 mysmsmantra"; 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.""); } ?> Edited December 8, 2020 by mysmsmantra Quote Link to comment Share on other sites More sharing options...
requinix Posted December 8, 2020 Share Posted December 8, 2020 You're trying to call send() on a PEAR_Error object. That would be $smtp. Apparently, $smtp is an error. You should check what the error is. Quote Link to comment 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.