Mailing for Thinkup – Hacking a Solution without using Sendmail

I’ve been meaning to try Thinkup for a long time now, and finally got around to trying it out.

I also decided this was also a good time to try a RaspberryPi and so the system I ended up running it on was not as complete as a normal linux server, or commercially provided host.

After installing dependencies, I quickly got stymied when I did not get a confirmation email.

Apparently this isn’t unique:

Also, their guidance is that; “We strongly recommend running ThinkUp on a web server which can send email.”

Using GMail as my SMTP server seemed the obvious choice, but that was before I learned that PHP’s mail() function does not support authentication in any way.

Apparently the most popular solution I found on Google was to use PHPMailer and this required some hacking that I wanted to document here.

I’m not sure if all of these steps are necessary, but it worked for me (TM):

  1. sudo vi /etc/php5/cgi/php.ini
    Add the line
  2. Download PHPMailer and extract it into your thinkup _lib directory [for me this was /usr/share/nginx/www/thinkup/_lib]
  3. Hack /usr/share/nginx/www/thinkup/_lib/class.Mailer
    • Add the following to the beginning of the file [right after "<?php"]: "ini_set("include_path", ".:./PHPMailer_v5.1/");
    • Find “} else { mail($to, $subject, $message, $mail_header);" and comment it out [with //]
    • then add:
      /** KLUDGE ADDED - START **/
      $mail = new PHPMailer();
      // $mail->SMTPDebug = 2;
      $mail->SMTPAuth = true;
      $mail->SMTPSecure = "tls";
      $mail->Host = '';
      $mail->Port = 587;
      $mail->Username = "";
      $mail->Password = "YOURPASSWORD";
      $mail->SetFrom("", "thingkup_notifications");
      $mail->Subject = $subject;
      $mail->Body = $message;
      $mail->WordWrap = 50;
      if(!$mail->Send()) {
      echo ‘Message was not sent.';
      echo ‘Mailer error: ‘ . $mail->ErrorInfo;
      else {
      echo ‘Message has been sent.';
      /** KLUDGE ADDED – END **/

I hope that helps someone, I can’t say it’s extensively tested (I wanted to blog it all before I forgot) but it worked in my example test script, which has to be close enough, right!

About jay

I'm trying to build something interactive where I can learn from others and hopefully share useful knowledge too.
This entry was posted in code, opensource. Bookmark the permalink.