Activiation URL empty Running into a weird issue with the site build I'm working currently: 

We're creating users based on email addresses coming from an event platform API and are sending activation emails to those users (from our plugin, 
using craft()-&gt;users-&gt;sendActivationEmail($user)).

The email gets sent out but the activation {{link}} is missing the host part of the URL. Instead we're seeing links like this: http:/actions/users/setpassword?code=bo2EDjfC7ebsrEpsx5T%7EyJ2Q6TRR0bI6&amp;id=912b5712-89f6-4dbc-9337-dec15b518536.

Add the host in between and the link works perfectly. I've tried setting a {{ siteUrl }} specifically the locale I'm in but that doesn't do the trick either.

When I go to the new user in the back-end and copy the activation URL there, that one is correct.

Any pointers as to what might be causing this? Thanks!

UPDATE

This is the craft/config/general.php we're using:

&lt;?php

if (!defined('PROJECTCODE')) {
    define('PROJECTCODE', strtolower('seapla'));
}

if (!defined('ENV')) {
    switch (strtolower($_SERVER['DOCUMENT_ROOT'])) {
        case '/data/sites/web/'.PROJECTCODE.'/subsites/'.PROJECTCODE.'.live.be/public';
            define('ENV', 'live');
            break;

        case '/data/sites/web/'.PROJECTCODE.'/subsites/'.PROJECTCODE.'.staging.be/public';
            define('ENV', 'staging');
            break;

        default:
            define('ENV', 'local');
            break;
    }
}

$settings = [
    'subscriptionPrice' =&gt; 275,
    'subscriptionPeriod' =&gt; 'P1Y',
    'invoicePrefix' =&gt; 'ECF2017',
    'autoLoginAfterAccountActivation' =&gt; true,
    'useEmailAsUsername' =&gt; true,
    'setPasswordPath' =&gt; '_members/_reset',
    'logoutPath'=&gt; 'e-learning',
    'defaultCpLanguage' =&gt; 'en_be',
    'defaultWeekStartDay' =&gt; 1,
    'logoutPath' =&gt; 'logout',
    'enableCsrfProtection' =&gt; true,
    'omitScriptNameInUrls' =&gt; true,
    'postCpLoginRedirect' =&gt; 'entries',
    'addTrailingSlashesToUrls' =&gt; false,
    'defaultSearchTermOptions' =&gt; array(
        'subLeft' =&gt; true,
        'subRight' =&gt; true,
    ),
    'environmentVariables' =&gt; [
        'basePath' =&gt; getcwd(),
        'baseUrl' =&gt; strtolower((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] != 'off' ? 'https://' : 'http://') . $_SERVER['SERVER_NAME']),
    ],
    'siteUrl' =&gt; strtolower((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] != 'off' ? 'https://' : 'http://') . $_SERVER['SERVER_NAME']),
];

switch (ENV) {
    case 'live':
        $settings['devMode'] = false;
        $settings['cache'] = true;
        break;

    case 'staging':
        $settings['devMode'] = true;
        $settings['cache'] = false;
        break;

    default:
        $settings['devMode'] = true;
        $settings['cache'] = false;
        break;
}

return $settings;
Figured it out by debugging getSiteUrl in UrlHelper.

Setting siteUrl like 'siteUrl' =&gt; strtolower((isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] != 'off' ? 'https://' : 'http://') . $_SERVER['SERVER_NAME']) is fine for browser requests, but $_SERVER['SERVER_NAME'] isn't available when running a console command.

The scheme is set correctly and since we have addTrailingSlashesToUrls set to false, the result became http:/.

Fixed for now by hard-coding siteUrl in our general.php for each environment.