7

I have been battling with this for some time now. I have built a custom component for forms and it uses Joomla's mail functions to send email. I have checked all the data to make sure it is correct but the email just does not send, $mailer->Send() returns true as well.

Turning on every style of error reporting reports no errors as well.

$mailer = JFactory::getMailer();
$mailer->setSender($settings->sender);
$mailer->addRecipient($settings->to);
$mailer->setSubject($settings->subject);
$mailer->isHTML(true);
$mailer->setBody($settings->body);
if($send = $mailer->Send()){
  //email worked
  //print_r($settings);
  //exit;
}else{
  echo 'error';
  exit;
}

This is the heart of the component where the email is sent, the $settings is an object I use to store the information that I need to send the email, and after what is read as a "successful" send it outputs all the proper information. However mandrill, the service we use for emails never gets the email, meaning that as far as I can tell it failed to connect to SMTP meaning it should of had an error at some point in the connection, but Joomla fails to see it.

This same code works on many other sites, the one in question is a subdomain and hosted with hostgator, though without any form of error I have no clue where to start looking for a fix.

  • Have you tried a simple script or standard Joomla contact form to see if that works? If not it might be either mail settings or a server problem. – Robert Went Apr 22 '14 at 19:29
8

Joomla uses PHPMailer as mail handler. PHPMailer has a nice SMTP log if you turn it on. You can do this by setting the SMTPDebug variable to true

$mailer = JFactory::getMailer();

$mailer->SMTPDebug = true;

$mailer->setSender($settings->sender);
$mailer->addRecipient($settings->to);
$mailer->setSubject($settings->subject);
$mailer->isHTML(true);
$mailer->setBody($settings->body);
if($send = $mailer->Send()){
  //email worked
  //print_r($settings);
  //exit;
}else{
  echo 'error';
  exit;
}

This should help you find the problem in the communication between Joomla and the smtp server.

  • 1
    Godly, in all the googling I did not see there was such a setting. SMTP -> ERROR: Failed to connect to server: Connection refused (111)SMTP connect failed. Now at least I know mandrill is blacklisting hostgator for some reason. – Jordan Ramstad Apr 22 '14 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.