Пример #1
0
    /**
     *
     */
    protected function send()
    {
        if (!attrib('to') || !attrib('body')) {
            pr(<<<'EOD'
------------------------------------------------------------
arguments:
    --to            send to email address
    --subject       email subject
    --body          email content message

example:
    php send --to xxx@gmail.com --subject "hello" --body "hi"
    php send --to xxx@gmail.com --body "$(cat message.txt)"
------------------------------------------------------------
EOD
);
            exit;
        }
        $getFrom = function () {
            $fromEmail = conf('gmail.email');
            $fromName = conf('gmail.name');
            return "{$fromName} <{$fromEmail}>";
        };
        $to = attrib('to');
        $subject = attrib('subject', 'not-subject');
        $body = attrib('body');
        $result = \GmailManager::sendMessage($getFrom(), $to, $subject, $body);
        if ($result) {
            pr('Send success');
        } else {
            pr('Send fail !');
        }
    }