protected function configureMail(array $config = [])
    {
        $config = array_merge([
            'MAIL_DRIVER'     => null,
            'MAIL_HOST'       => null,
            'MAIL_PORT'       => null,
            'MAIL_USERNAME'   => null,
            'MAIL_PASSWORD'   => null,
            'MAIL_ADDRESS'    => null,
            'MAIL_NAME'       => null,
            'MAIL_ENCRYPTION' => null,
        ], $config);

        // Don't continue with these settings if we're not interested in notifications.
        if (!$this->confirm('Do you want Cachet to send mail notifications?')) {
            return;
        }

        $config['MAIL_DRIVER'] = $this->choice('What driver do you want to use to send notifications?', [
            'smtp'      => 'SMTP',
            'mail'      => 'Mail',
            'sendmail'  => 'Sendmail',
            'mailgun'   => 'Mailgun',
            'mandrill'  => 'Mandrill',
            'ses'       => 'Amazon SES',
            'sparkpost' => 'SparkPost',
            'log'       => 'Log (Testing)',
        ]);

        if (!$config['MAIL_DRIVER'] === 'log') {
            if ($config['MAIL_DRIVER'] === 'smtp') {
                $config['MAIL_HOST'] = $this->ask('Please supply your mail server host');
            }

            $config['MAIL_ADDRESS'] = $this->ask('What email address should we send notifications from?');
            $config['MAIL_USERNAME'] = $this->ask('What username should we connect as?');
            $config['MAIL_PASSWORD'] = $this->secret('What password should we connect with?');
        }

        // Format the settings ready to display them in the table.
        $this->formatConfigsTable($config);

        if (!$this->confirm('Are these settings correct?')) {
            return $this->configureMail($config);
        }

        foreach ($config as $setting => $value) {
            $this->writeEnv($setting, $value);
        }
    }