Created
January 27, 2017 15:35
-
-
Save nullvariable/5ed32739ddfb66d08577c8f877bb06b6 to your computer and use it in GitHub Desktop.
set Craft to use local mailhog instance. Just drop in an existing plugin's init function, refresh and then remove (assumes you're using official Mailhog docker instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mailhog_name = getenv('MAILHOG_NAME'); | |
$mailhog_port = getenv('MAILHOG_PORT'); | |
if ($mailhog_name && $mailhog_port) { | |
$hostname = array_slice(explode('/', getenv('MAILHOG_NAME')), -1, 1)[0]; | |
$port = array_slice(explode(':', getenv('MAILHOG_PORT')), -1, 1)[0]; | |
$settings = craft()->systemSettings->getSettings('email'); | |
$settings['protocol'] = 'smtp'; | |
$settings['port'] = $port; | |
$settings['host'] = $hostname; | |
$settings['timeout'] = 10; | |
$settings['smtpKeepAlive'] = ''; | |
$settings['smtpAuth'] = ''; | |
$settings['smtpSecureTransportType'] = 'none'; | |
craft()->systemSettings->saveSettings('email', $settings); | |
echo "Settings updated to use mailhog\n"; | |
} else { | |
echo "Mailhog environment variables not found, skipping\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment