Skip to content

Commit

Permalink
added email via smtp server availability
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevalstar committed Jan 18, 2013
1 parent 40a6c8e commit fa73305
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions class/email.class.php
Expand Up @@ -3,7 +3,9 @@
class email{

static function send($to, $to_name, $subject, $message, $messageHTML = false){
$transport = Swift_MailTransport::newInstance();
$transport = Swift_SmtpTransport::newInstance(EMAIL_SERVER, 25)
->setUsername(EMAIL_FROM)
->setPassword(EMAIL_PASSWORD);
$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance()
Expand All @@ -12,7 +14,7 @@ static function send($to, $to_name, $subject, $message, $messageHTML = false){
->setSubject($subject)

// Set the From address with an associative array
->setFrom(array('no-reply@konradgroup.com' => 'KG Game Knight'))
->setFrom(array(EMAIL_FROM => EMAIL_FROM_NAME))

// Set the To addresses with an associative array
->setTo(array($to => $to_name))
Expand All @@ -34,7 +36,10 @@ static function send_all($subject, $message, $messageHTML = false){
foreach($users as $v)
$user_array[$v['email']] = $v['name_first'] . ' ' . $v['name_last'];

$transport = Swift_MailTransport::newInstance();
$transport = Swift_SmtpTransport::newInstance(EMAIL_SERVER, 25)
->setUsername(EMAIL_FROM)
->setPassword(EMAIL_PASSWORD);

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance()
Expand All @@ -43,7 +48,7 @@ static function send_all($subject, $message, $messageHTML = false){
->setSubject($subject)

// Set the From address with an associative array
->setFrom(array('no-reply@konradgroup.com' => 'KG Game Knight'))
->setFrom(array(EMAIL_FROM => EMAIL_FROM_NAME))

// Set the To addresses with an associative array
->setTo($user_array)
Expand Down
5 changes: 5 additions & 0 deletions include/config.inc.example
Expand Up @@ -7,6 +7,11 @@ define('DB_DB', 'kggamenight');

define('ENV', 'development');

define('EMAIL_FROM', 'no-reply@example.com');
define('EMAIL_FROM_NAME', 'KG Game Knight');
define('EMAIL_SERVER', 'mail.example.com');
define('EMAIL_PASSWORD', 'password');

define('LOGIT_WEB', __DIR__.'/../log/web.log');
define('LOGIT_CRON', __DIR__.'/../log/cron.log');
define('LOGIT_COMMON', __DIR__.'/../log/common.log');
Expand Down
2 changes: 1 addition & 1 deletion template/manage/games_item.tpl
@@ -1,6 +1,6 @@
{extends 'layout.tpl'}
{block "navbar-top"}
<form class="form-search navbar-form pull-right">
<form class="form-search navbar-form pull-right" action="/games">
<div class="input-append">
<input type="text" name="filter" class="input-medium search-query" placeholder="Search Games" />
<button class="btn" type="submit">Search</button>
Expand Down

0 comments on commit fa73305

Please sign in to comment.