Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:01:28+00:00 2026-06-02T16:01:28+00:00

I get this error PHP Fatal error: Call to a member function Send() on

  • 0

I get this error PHP Fatal error: Call to a member function Send() on a non-object. This error concerns the line if(!$mail->Send()).

I searched on another forum and it might be about using “load->” somewhere but I’m not sure why and how.

function New_Mail($email,$firstname,$surname,$body, $subject, $altBody, $wordwrap){

$mail             = new PHPMailer();

$mail->IsSMTP();
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the server
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port

$mail->Username   = "xxxxxxx@gmail.com";  // GMAIL username
$mail->Password   = "xxxxx";            // GMAIL password

$mail->From       = "xxxxxxx@gmail.com";
$mail->FromName   = "Admin";

$mail->Subject    = $subject;
$mail->AltBody    =  $altBody;//Text Body
$mail->WordWrap   = $wordwrap; // set word wrap
$mail->AddAddress($email,$firstname." ".$surname);

$mail->MsgHTML($body);
$mail->AddReplyTo("replyto@yourdomain.com","Admin");
$mail->SMTPDebug = 1;

$mail->IsHTML(true); // send as HTML

}

$mail=New_Mail($email,$firstname,$surname,'This is the body','Welcome','this is the alternate body',100);

if(!$mail->Send()) {
  echo "Mailer Error: " . $mail->ErrorInfo;
} else {
// nothing is displayed
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:01:29+00:00Added an answer on June 2, 2026 at 4:01 pm

    You’re getting the error because $mail at the bottom of your code is not an object. You have this snippet of code:

    $mail=New_Mail($email,$firstname,$surname,'This is the body','Welcome','this is the alternate body',100);
    

    However, New_Mail() doesn’t actually return anything, so $mail is an empty variable.

    One way to fix this is to return the $mail object in New_Mail().

    Another note: be careful when choosing variable names. You’re using the varname $mail within the New_Mail() function and outside of the function. This is perfectly fine, but just remember that the $mail object from within New_Mail() is no longer in scope by the time you call Send(). That’s why PHP is throwing up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a fatal Call to a member function on a non-object error in
This code get an error : Fatal error: Call to a member function prepare()
I get the error PHP Fatal error: Call to a member function execute() on
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of
When I execute this code I get an error saying PHP Fatal error: Call
I'm having trouble with this PHP script where I get the error Fatal error
I get this error when I try to call $func('something') : if(($object instanceof MyObject)
THE SUMMARY: When I call .../index.php/product, I receive: Fatal error: Call to a member
I have the error of [12-Jul-2011 11:05:43] PHP Fatal error: Call to a member
I get this error when I try to use a model: fatal error: Call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.