Jump to content

PHPMailer Installation/Test ERROR MESSAGES


SystemOverload

Recommended Posts

Hey

 

I'm on PHP 5.3.4ish.  I've recently started using PHPMailer, but when testing it, end up with an "Could not instantiate mail function." error.

 

Does anyone have any ideas?

 

My files are laid out as below:

 

/emailtest.php

- Calls fn_mailer("[email protected]","Test Email Recipient","Subject","BODY")

/includes/functions/fn_comms.php

- Contains function fn_mailer(), a simple wrapper that accesses the PHPMailer Functionality...

/includes/functions/phpmailer/class.phpmailer.php

/includes/functions/phpmailer/class.pop3.php

/includes/functions/phpmailer/class.smtp.php

 

fn_mailer()

function fnMailer ($varToEmail, $varToName, $varSubject, $varBody) {
// - -- --- Wrapper for PHP Mailer Class Interface ------------------------------------
require_once 'phpmailer/class.phpmailer.php';

$mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

try {
  $mail->AddReplyTo('[email protected]', 'Support');
  $mail->AddAddress($varToEmail, $varToName);
  $mail->SetFrom('[email protected]', 'Admin');
  $mail->Subject = $varSubject;
  $mail->AltBody = 'To view this email message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
  //$mail->MsgHTML(file_get_contents('contents.html'));
  $mail->MsgHTML($varBody);
  //$mail->AddAttachment('images/phpmailer.gif');      // attachment
  //$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
  $mail->Send();
          echo "Message Sent OK</p>\n";
} catch (phpmailerException $e) {
  echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
  echo $e->getMessage(); //Boring error messages from anything else!
}
// - -- --- END OF WRAPPER ------------------------------------------------------------------
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.