SystemOverload Posted September 16, 2009 Share Posted September 16, 2009 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 ------------------------------------------------------------------ } Link to comment https://forums.phpfreaks.com/topic/174486-phpmailer-installationtest-error-messages/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.