Completed
Push — master ( fcc3a0...a5af0d )
by Stefano
02:15
created

Ses   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 7
c 3
b 1
f 0
lcom 1
cbo 1
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 16 5
A send() 0 5 2
1
<?php
2
3
/**
4
 * Email\SES
5
 *
6
 * Email\SES SMTP driver.
7
 *
8
 * @package core
9
 * @author [email protected]
10
 * @copyright Caffeina srl - 2015 - http://caffeina.it
11
 */
12
13
namespace Email;
14
15
class Ses extends Smtp {
16
17
  public function __construct($options = null) {
18
    $options  = (object)$options;
19
    $region   = isset($options->region) ? $options->region : 'eu-west-1';
20
    if (empty($options->username) || empty($options->password))
21
       throw new \Exception("[Core.Email.SES] You must provide Amazon SES SMTP username and password", 1);
22
23
    Smtp::__construct([
24
      'host'     => "email-smtp.{$region}.amazonaws.com",
25
      'secure'   => true,
26
      'port'     => 465,
27
      'username' => $options->username,
28
      'password' => $options->password,
29
    ]);
30
31
    if (!empty($options->from)) $this->from($options->from);
32
  }
33
34
  public function send(){
35
    if (empty($this->from->full))
36
       throw new \Exception("[Core.Email.SES] Amazon SES needs a registered `from` address", 1);
37
    return Smtp::send();
38
  }
39
40
}
41
42