0

I've been working on a login system and keep running into errors when trying to send e-mails over PHPMailer, can't get any better in-site into the errors so any help?

Function that doesn't work:

function SendUserConfirmationEmail(&$formvars)
{
    $mailer = new PHPMailer(true);
    
    $mailer->CharSet = 'utf-8';
    
    $mailer->AddAddress($formvars['email'],$formvars['name']);
    
    $mailer->Subject = "Your registration with ".$this->sitename;

    $mailer->From = $this->GetFromAddress();        
    
    $confirmcode = $formvars['confirmcode'];
    
    $confirm_url = $this->GetAbsoluteURLFolder().'/confirmreg.php?code='.$confirmcode;
    
    $mailer->Body ="Hello ".$formvars['name']."\r\n\r\n".
    "Thanks for your registration with ".$this->sitename."\r\n".
    "Please click the link below to confirm your registration.\r\n".
    "$confirm_url\r\n".
    "\r\n".
    "Regards,\r\n".
    "Webmaster\r\n".
    $this->sitename;

    if(!$mailer->Send())
    {
        $mailer->ErrorInfo;
        $this->HandleError("Failed sending registration confirmation email.");
        return false;
    }
    return true;
}

UPDATE:

Sorry for no activity, I had to make myself a autoloader and request the class.phpmailer file as require_once!

Ezikiel
  • 25
  • 8
  • 1
    What are the errors? – Erik Aug 17 '21 at 12:23
  • The one I have in HandleError, "Failed sending registration confirmation email." – Ezikiel Aug 17 '21 at 12:34
  • That's the notice you created when something failed, can I get the actual error message please? You can read about capturing errors here: `https://stackoverflow.com/questions/2386544/error-handling-with-phpmailer` – Erik Aug 17 '21 at 21:11
  • Ah yep! Sorry bout that, using "echo 'Mailer Error: ' . $mailer->ErrorInfo;", gives me a: "Mailer Error: Could not instantiate mail function. " – Ezikiel Aug 17 '21 at 22:41
  • Are you including the library correctly? Did you install with composer? if not, did you include: – Erik Aug 18 '21 at 02:24

0 Answers0