Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
2.6k views
in Q2A Core by
You can write an example of the modified file qa-external/qa-external-emailer.php?
To send mail through Gmail. Sendmail on hosting does not work.

P.S. I do not know PHP


(Вы можете написать пример изменённого файла qa-external/qa-external-emailer.php?
Что бы отправлять почту через Gmail. Sendmail на хостинге не работает.
P.С. Я не знаю PHP )
related to an answer for: How do I configure mail?
by
Same here. Sendmail on hosting does not work.

1 Answer

+6 votes
by
 
Best answer

The Q2A install of PHPMailer seems to lack the necessary SMTP class (class.smtp.php) for sending via SMTP.

So, first fetch a version of PHPmailer 2 which provides it. I downloaded version 2.0.4 from here:

http://sourceforge.net/projects/phpmailer/ 

Unzip that, get the file, and put it  in /qa-external/.

Then copy in the example emailer, call it qa-external-emailer.php

You will need the qa_send_email() function to look something like this:



function qa_send_email($params)
{
  require_once QA_INCLUDE_DIR.'qa-class.phpmailer.php';
  require_once dirname(__FILE__) . '/class.smtp.php';
 
  $mailer=new PHPMailer();
  $mailer->CharSet='utf-8';
  $mailer->IsSMTP(); // enable SMTP
  $mailer->SMTPAuth = true;
  $mail->SMTPSecure = 'ssl';
  $mailer->Host = "ssl://smtp.gmail.com:465";
  $mailer->Username = "<your gmail email address here>";
  $mailer->Password = "<your gmail password here >";
 
 
  $mailer->From=$params['fromemail'];
  $mailer->Sender=$params['fromemail'];
  $mailer->FromName=$params['fromname'];
  $mailer->AddAddress($params['toemail'], $params['toname']);
  $mailer->Subject=$params['subject'];
  $mailer->Body=$params['body'];
 
  if ($params['html'])
    $mailer->IsHTML(true);
 
  return $mailer->Send();
}
 
Put in your whole gmail email address and password above, and remember to set QA_EXTERNAL_EMAILER to true in qa-config.php.
 
by
i followed this but it still didn't work...
by
What sort of hosting provider are you using? Some hosting providers will not allow you the outgoing connection to talk to gmail.
by
I'm using bluehost. sendfeedback form works well except notification and pm.
by
Where can I find this example emailer?
...