SmarterMail Help

Automating Login to SmarterMail

Companies using SmarterMail can easily automate user entry into the mail application by configuring the auto-login functionality. The HTML code shown below demonstrates how you can make a text link on a website (e.g. "Log into your mail") that automatically logs a user in to the SmarterMail site. By putting this hidden form on a simple web page, you can fill in the "Domain", "Email Address", and "Password" information by hard-coding the data or through a scripting language like ASP, ASP.Net, or ColdFusion. This implementation of auto-login works seamlessly across domains, so the two applications do not have to be hosted on the same server.

Some notes about the example code listed below:

We have the form values set to generic text (e.g. "USERNAME_GOES_HERE") to show where you would hard code values that are submitted to the login page. You could also dynamically generate these values using a scripting language like ASP or ColdFusion. A sample ASP script would substitute var domain = "USERNAME_GOES_HERE"; with var domain = "<% =email %>".

The form action shown, https://DOMAIN_GOES_HERE, uses the default location of the Smartermail Web Interface. If you have created a separate web site for Smartermail or if you assign a different IP address for Smartermail within IIS, this action would have to be altered to reflect this change. For example, a modified form action might take the format of In addition, this code assumes that your SmarterMail site is secured with SSL/TLS. If it is not, be sure to change the var domain URL from https to http.

Auto-Login Sample HTML Code

      <!DOCTYPE html> 
<meta charset="utf-8">
function autoLogin() {
var domain = "https://DOMAIN_GOES_HERE";
var username = "USERNAME_GOES_HERE";
var password = "PASSWORD_GOES_HERE";

var xhr = new XMLHttpRequest();'POST', domain + '/api/v1/auth/authenticate-user');
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.onload = function() {
if (xhr.status === 200) {
var success = JSON.parse(xhr.responseText);

if (!success.success) {
var res = "";
res = success.message
res = success.status
document.getElementById("errors").innerText = res;
window.location.href = success.autoLoginUrl;
document.getElementById("errors").innerText = failure.message || failure;
username: username,
password: password,
retrieveAutoLoginToken: true
<body onload="autoLogin()">
<div id="errors"></div>