Jyxo\Mail\Sender\Smtp::data PHP Method

data() public method

Sends email headers and body.
public data ( string $header, string $body ) : self
$header string Headers
$body string Body
return self
    public function data(string $header, string $body) : self
    {
        $lineEnds = [\Jyxo\Mail\Sender::LINE_END . '.' => self::LINE_END . '..', \Jyxo\Mail\Sender::LINE_END => self::LINE_END];
        $header = strtr($header, $lineEnds);
        $body = strtr($body, $lineEnds);
        if ('.' == $body[0]) {
            $body = '.' . $body;
        }
        $this->commandData();
        $this->writeData(trim($header));
        $this->writeData('');
        $this->writeData($body);
        $this->writeData('.');
        $response = $this->readData();
        if ('250' !== substr($response, 0, 3)) {
            throw new SmtpException('SEND: ' . $response);
        }
        return $this;
    }