Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
45.45% covered (warning)
45.45%
5 / 11
75.00% covered (success)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Sendmail
45.45% covered (warning)
45.45%
5 / 11
75.00% covered (success)
75.00%
3 / 4
18.39
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 setParams
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 getParams
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 send
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2/**
3 * Pop PHP Framework (http://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@nolainteractive.com>
7 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
8 * @license    http://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Mail\Transport;
15
16use Pop\Mail\Message;
17
18/**
19 * Sendmail transport class
20 *
21 * @category   Pop
22 * @package    Pop\Mail
23 * @author     Nick Sagona, III <dev@nolainteractive.com>
24 * @copyright  Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)
25 * @license    http://www.popphp.org/license     New BSD License
26 * @version    3.6.0
27 */
28class Sendmail extends AbstractTransport
29{
30
31    /**
32     * Sendmail params
33     * @var string
34     */
35    protected $params = null;
36
37    /**
38     * Constructor
39     *
40     * Instantiate the Sendmail transport object
41     *
42     * @param  string $params
43     */
44    public function __construct($params = null)
45    {
46        if (null !== $params) {
47            $this->setParams($params);
48        }
49    }
50
51    /**
52     * Set the params
53     *
54     * @param  string $params
55     * @return Sendmail
56     */
57    public function setParams($params)
58    {
59        $this->params = $params;
60        return $this;
61    }
62
63    /**
64     * Get the params
65     *
66     * @return string
67     */
68    public function getParams()
69    {
70        return $this->params;
71    }
72
73    /**
74     * Send the message
75     *
76     * @param  Message $message
77     * @return boolean
78     */
79    public function send(Message $message)
80    {
81        $headers = $message->getHeadersAsString(['Subject', 'To']);
82
83        if ((null !== $headers) && (null !== $this->params)) {
84            return mail($message->getHeader('To'), $message->getSubject(), $message->getBody(), $headers, $this->params);
85        } else if (null !== $headers) {
86            return mail($message->getHeader('To'), $message->getSubject(), $message->getBody(), $headers);
87        } else {
88            return mail($message->getHeader('To'), $message->getSubject(), $message->getBody());
89        }
90    }
91
92}