0

I have a basic PHP contact form which I use on a couple of sites, which sends email using the SendInBlue API.

My problem is that I have the form working perfectly on 1 site, now I am using the EXACT same code for a second site and just changing the email, name, etc - however when testing it I now get this error:

Fatal error: Call to undefined method Mailin::send_email() in /URL/contactpage.php on line 71

FYI, line 71 is:

$mailin->send_email($data);

I have attached the complete code below - this works perfectly on 1 site, but I get this error on my second site.

Any ideas?

Thank you!

<?php

//Email Details for Form Notifications
$email_to =   'Test@test.com'; //the address to which the email will be sent 
$email_to_name     =  'Test';

//Form Fields
$fname     =   $_POST['firstname'];
$lname     =   $_POST['lastname'];
$email    =   $_POST['email'];
$fullmessage    =   $_POST['message'];

//Subject Lines
$subject_to  =   'Test';
$subject_touser  =   'Test';

//URL Redirects
$confirm  =   'TestConfirm';
$errorurl  =    'TestError';

//Validate
$emailval = filter_var( $email, FILTER_VALIDATE_EMAIL );
if ($emailval == false)
{
    header("Location: $errorurl");
} else {

    // The email to us
    $message_to = 'Message here';
    //

    // The email to them
    $message_touser = 'Message here';
    //

    require('Mailin.php');

    //Notification Email
    $mailin = new Mailin('https://api.sendinblue.com/v2.0','MY_KEY');
    $data = array( "to" => array($email_to=>$email_to_name),
                "cc" => array($email_to_cc=>$email_to_cc_name),
                "from" => array($email,$fname),
                "subject" => $subject_to,
                "html" => $message_to
    );

    $mailin->send_email($data);

    //Email to User
    $mailin = new Mailin('https://api.sendinblue.com/v2.0','MY_KEY');
    $data2 = array( "to" => array($email=>$fname),
                "from" => array($email_to,$email_to_name),
                "subject" => $subject_touser,
                "html" => $message_touser
    );

    $mailin->send_email($data2);  

    header("Location: $confirm");

}

?>

Grokify
  • 15,092
  • 6
  • 60
  • 81
Scott
  • 57
  • 1
  • 10
  • So I have discovered that this code works PERFECTLY on one domain, but on a separate URL on the same domain it returns the error... So the code works, but it doesn't want to exist in certain places. All required files are exactly the same... – Scott May 07 '16 at 05:26

1 Answers1

0

I was using a deprecated Mailin.php. Updated the file and everything works now.

Scott
  • 57
  • 1
  • 10