Completed
Push — master ( 7fe22c...328c86 )
by Stefano
02:25
created

Ses::send()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
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 - 2016 - http://caffeina.com
11
 */
12
13
namespace Email;
14
15
class Ses extends Smtp {
16
17
  public function onInit($options) {
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 an Amazon SES SMTP username and password", 1);
22
23
    Smtp::onInit([
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);
0 ignored issues
show
Bug introduced by
The method from() does not seem to exist on object<Email\Ses>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
  }
33
34
  public function onSend(Envelope $envelope){
35
    if (!$envelope->from())
36
       throw new \Exception("[core.email.ses] Amazon SES needs a registered `from` address", 1);
37
    return Smtp::send($envelope);
0 ignored issues
show
Bug introduced by
The method send() does not seem to exist on object<Email\Smtp>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
  }
39
40
}
41
42