Home Contact Buy Now
Home Download Video Free Buy Now Site Map Contact

Configuring Mail in Time Tracker

Anuko Time Tracker uses email to send reports and invoices. Also, password reset feature in Time Tracker depends on working mail. Time Tracker configuration file ./WEB-INF/config.php has the following directives for mail.
// Default sender for mail.
//
define('SENDER', '"Anuko Time Tracker" <no-reply@timetracker.anuko.com>');

// MAIL_MODE - mail sending mode. Can be 'mail' or 'smtp'.
// 'mail' - sending through php mail() function.
// 'smtp' - sending directly through SMTP server.
//
define('MAIL_MODE', 'smtp');
define('MAIL_SMTP_HOST', 'localhost'); // For gmail use 'ssl://smtp.gmail.com' instead of 'localhost' and port 465.
// define('MAIL_SMTP_PORT', '465');
// define('MAIL_SMTP_USER', 'yourname@yourdomain.com');
// define('MAIL_SMTP_PASSWORD', 'yourpassword');
// define('MAIL_SMTP_AUTH', 'true');
// define('MAIL_SMTP_DEBUG', 'true');
The SENDER constant defines what users see in the From field in emails that Time Tracker sends. For your own domain set the SENDER accordingly, for example:
define('SENDER', '"Mydomain Time Tracker" <noreply@mydomain.com>');
Note: If your domain is set with some form of sender authentication using SPF, DKIM, or DMARC then you should comply with the sender authentication policy for good deliverability. In the case of SPF it means that the mail server must be authorized to send mail for your domain (as configured in its DNS records). In other words, mail must originate from a legitimate email server and not necessarily from a machine where Time Tracker application runs.

Two Methods to Send Mail

There are two methods to send mail from Time Tracker - either through php mail function or directly through SMTP server. Depending on where Time Tracker is hosted, either one or both methods may work. If it is unknown how hosting is configured try the mail method first.

Using PHP mail

define('MAIL_MODE', 'mail');
If you define MAIL_MODE as mail then mail will go through PHP mail() function as configured in php.ini.

On Unix platforms, it is usually done by calling Mail Submission Agent (MSA) and transferring parameters and message body to its standard input. Often sendmail is used for this purpose or a wrapper script of the same name for another Mail Transfer Agent (MTA) that emulates original sendmail behaviour.

Using SMTP Mail Server

define('MAIL_MODE', 'smtp');
In this case mail is sent by connecting to outgoing mail server on TCP port 25 (unless another port is specified) and using SMTP protocol.

Sending Mail without Authentication

Additional parameters:
define('MAIL_SMTP_HOST', 'my.smtp.relay'); // Name or IP address of outgoing mail server. Usually, localhost.
define('MAIL_SMTP_DEBUG', 'true'); // Output debug information if you need to troubleshoot mail sending problems.
On Windows platforms, it is usually done via SMTP connection as configured in php.ini.

When SMTP server is used, it must be available on the specified TCP port (usually 25) and allow to relay mail from the domain where Time Tracker is hosted without authentication. Below is an example of debug output when mail server does not allow sending mail without authentication.
DEBUG: Recv: 220 localhost.localdomain ESMTP Postfix
DEBUG: Send: EHLO localhost
DEBUG: Recv: 250-localhost.localdomain
DEBUG: Recv: 250-PIPELINING DEBUG: Recv: 250-SIZE 10240000
DEBUG: Recv: 250-VRFY
DEBUG: Recv: 250-ETRN
DEBUG: Recv: 250-ENHANCEDSTATUSCODES
DEBUG: Recv: 250-8BITMIME
DEBUG: Recv: 250 DSN
DEBUG: Send: MAIL FROM:
DEBUG: Recv: 250 2.1.0 Ok
DEBUG: Send: RCPT TO:
DEBUG: Recv: 554 5.7.1 : Relay access denied
DEBUG: Send: RSET
DEBUG: Recv: 250 2.0.0 Ok
And here is an example of a Time Tracker screen when MAIL_SMTP_DEBUG is set to true. As you can see, some useful information is available on top of the screen for troubleshooting, in addition to the "Error sending mail" message in the middle.

Time Tracker prints debug info on top when MAIL_SMTP_DEBUG is true
Time Tracker prints debug info on top when MAIL_SMTP_DEBUG is true

Note: to see debug output with line feeds you can view page source.

Sending Mail with Authentication via Email Provider

To configure Time Tracker to send authenticated emails through a mail service provider use all of the following parameters. This example shows how to use gmail service.
define('MAIL_MODE', 'smtp');
define('MAIL_SMTP_HOST', 'ssl://smtp.gmail.com');
define('MAIL_SMTP_PORT', '465');
define('MAIL_SMTP_USER', 'yourname@yourdomain.com');
define('MAIL_SMTP_PASSWORD', 'yourpassword');
define('MAIL_SMTP_AUTH', 'true');
// define('MAIL_SMTP_DEBUG', 'true');
For other providers change MAIL_SMTP_HOST and MAIL_SMTP_PORT accordingly. Obtain the values to use from your email provider.

Troubleshooting Mail

There are a few things to check if mail is not working.
  • Use MAIL_SMTP_DEBUG. For this, uncomment the define('MAIL_SMTP_DEBUG', 'true'); line in config.php.
  • Examine PHP errors. They can be printed on a page or in web server error log.
  • See mail server logs for additional error information.

Mail in Time Tracker Virtual Appliance

Time Tracker virtual appliance is a pre-packaged, ready-to-use application with already working email. All of the information above is valid for the appliance. Its configuration file is located at /var/www/html/WEB-INF/config.php with the following lines in it:
define('MAIL_MODE', 'smtp');
define('MAIL_SMTP_HOST', 'localhost');
postfix program runs in the appliance and is capable to deliver Time Tracker emails.


Time Tracker Install Guide