<?php defined('BASEPATH') OR exit('No direct script access allowed');

$config['email'] = array();
$config['email']['protocol'] = 'smtp';
$config['email']['mailtype'] = 'html';
$config['email']['charset'] = 'UTF-8';
$config['email']['newline'] = "\r\n";

if (!empty($_SERVER['AWS_SMTP']))
{
	if (!empty($_SERVER['SMTP_HOST']))
	{
		$config['email']['smtp_host'] = $_SERVER['SMTP_HOST'];
	}

	if (!empty($_SERVER['SMTP_PORT']))
	{
		$config['email']['smtp_port'] = $_SERVER['SMTP_PORT'];
	}

	if (!empty($_SERVER['SMTP_USER']))
	{
		$config['email']['smtp_user'] = $_SERVER['SMTP_USER'];
		$config['email']['smtp_from'] = $config['email']['smtp_from_name'] = $config['email']['smtp_user']; 
	}

	if (!empty($_SERVER['SMTP_PASS']))
	{
		$config['email']['smtp_pass'] = $_SERVER['SMTP_PASS'];
	}
	if (!empty($_SERVER['SMTP_FROM']))
	{
		$config['email']['smtp_from'] = $_SERVER['SMTP_FROM'];
	}
	if (!empty($_SERVER['SMTP_FROM_NAME']))
	{
		$config['email']['smtp_from_name'] = $_SERVER['SMTP_FROM_NAME'];
	}
}
else if (is_readable(FCPATH . 'env.php'))
{
	include(FCPATH . 'env.php');

	if (!empty($env_email)) {
		$config['email'] = $env_email;
	}
}


