Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Original email port #2092

Merged
merged 2 commits into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions app/Config/Email.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
<?php
namespace Config;

class Email
{

/**
* @var string
*/
public $fromEmail;

/**
* @var string
*/
public $fromName;

/**
* The "user agent"
*
* @var string
*/
public $userAgent = 'CodeIgniter';

/**
* The mail sending protocol: mail, sendmail, smtp
*
* @var string
*/
public $protocol = 'mail';

/**
* The server path to Sendmail.
*
* @var string
*/
public $mailPath = '/usr/sbin/sendmail';

/**
* SMTP Server Address
*
* @var string
*/
public $SMTPHost;

/**
* SMTP Username
*
* @var string
*/
public $SMTPUser;

/**
* SMTP Password
*
* @var string
*/
public $SMTPPass;

/**
* SMTP Port
*
* @var integer
*/
public $SMTPPort = 25;

/**
* SMTP Timeout (in seconds)
*
* @var integer
*/
public $SMTPTimeout = 5;

/**
* Enable persistent SMTP connections
*
* @var boolean
*/
public $SMTPKeepAlive = false;

/**
* SMTP Encryption. Either tls or ssl
*
* @var string
*/
public $SMTPCrypto = 'tls';

/**
* Enable word-wrap
*
* @var boolean
*/
public $wordWrap = true;

/**
* Character count to wrap at
*
* @var integer
*/
public $wrapChars = 76;

/**
* Type of mail, either 'text' or 'html'
*
* @var string
*/
public $mailType = 'text';

/**
* Character set (utf-8, iso-8859-1, etc.)
*
* @var string
*/
public $charset = 'UTF-8';

/**
* Whether to validate the email address
*
* @var boolean
*/
public $validate = false;

/**
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
*
* @var integer
*/
public $priority = 3;

/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*
* @var string
*/
public $CRLF = "\r\n";

/**
* Newline character. (Use “\r\n” to comply with RFC 822)
*
* @var string
*/
public $newline = "\r\n";

/**
* Enable BCC Batch Mode.
*
* @var boolean
*/
public $BCCBatchMode = false;

/**
* Number of emails in each BCC batch
*
* @var integer
*/
public $BCCBatchSize = 200;

/**
* Enable notify message from server
*
* @var boolean
*/
public $DSN = false;

}
54 changes: 37 additions & 17 deletions system/Config/Services.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

/**
* CodeIgniter
*
Expand Down Expand Up @@ -98,6 +97,7 @@
*/
class Services extends BaseService
{

/**
* The cache class provides a simple way to store and retrieve
* complex data for later.
Expand Down Expand Up @@ -179,17 +179,40 @@ public static function curlrequest(array $options = [], ResponseInterface $respo
}

return new CURLRequest(
$config,
new URI($options['base_uri'] ?? null),
$response,
$options
$config,
new URI($options['base_uri'] ?? null),
$response,
$options
);
}

//--------------------------------------------------------------------

/**
* The Encryption class provides two-way encryption.
* The Email class allows you to send email via mail, sendmail, SMTP.
*
* @param null $config
* @param boolean $getShared
*
* @return \CodeIgniter\Email\Email|mixed
*/
public static function email($config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('email', $config);
}
if (empty($config))
{
$config = new \Config\Email();
}
$email = new \CodeIgniter\Email\Email($config);
$email->setLogger(static::logger(true));
return $email;
}

/**
* The Encryption class provides two-way encryption.
*
* @param mixed $config
* @param boolean $getShared
Expand Down Expand Up @@ -380,13 +403,11 @@ public static function language(string $locale = null, bool $getShared = true)
if ($getShared)
{
return static::getSharedInstance('language', $locale)
->setLocale($locale);
->setLocale($locale);
}

$locale = ! empty($locale)
? $locale
: static::request()
->getLocale();
$locale = ! empty($locale) ? $locale : static::request()
->getLocale();

return new Language($locale);
}
Expand Down Expand Up @@ -582,10 +603,10 @@ public static function request(App $config = null, bool $getShared = true)
}

return new IncomingRequest(
$config,
new URI(),
'php://input',
new UserAgent()
$config,
new URI(),
'php://input',
new UserAgent()
);
}

Expand Down Expand Up @@ -638,7 +659,7 @@ public static function redirectResponse(App $config = null, bool $getShared = tr

$response = new RedirectResponse($config);
$response->setProtocolVersion(static::request()
->getProtocolVersion());
->getProtocolVersion());

return $response;
}
Expand Down Expand Up @@ -905,5 +926,4 @@ public static function typography(bool $getShared = true)
}

//--------------------------------------------------------------------

}
Loading