Mailgun\Mailgun::sendMessage PHP Method

sendMessage() public method

This function allows the sending of a fully formed message OR a custom MIME string. If sending MIME, the string must be passed in to the 3rd position of the function call.
public sendMessage ( string $workingDomain, array $postData, array $postFiles = [] ) : stdClass
$workingDomain string
$postData array
$postFiles array
return stdClass
    public function sendMessage($workingDomain, $postData, $postFiles = [])
    {
        if (is_array($postFiles)) {
            return $this->post("{$workingDomain}/messages", $postData, $postFiles);
        } elseif (is_string($postFiles)) {
            $tempFile = tempnam(sys_get_temp_dir(), 'MG_TMP_MIME');
            $fileHandle = fopen($tempFile, 'w');
            fwrite($fileHandle, $postFiles);
            $result = $this->post("{$workingDomain}/messages.mime", $postData, ['message' => $tempFile]);
            fclose($fileHandle);
            unlink($tempFile);
            return $result;
        } else {
            throw new Exceptions\MissingRequiredMIMEParameters(ExceptionMessages::EXCEPTION_MISSING_REQUIRED_MIME_PARAMETERS);
        }
    }

Usage Example

Ejemplo n.º 1
1
 public function send()
 {
     # Include the Autoloader (see "Libraries" for install instructions)
     # Instantiate the client.
     $mgClient = new Mailgun('');
     $domain = "";
     # Make the call to the client.
     $result = $mgClient->sendMessage($domain, array('from' => 'InfoJr UFBA <*****@*****.**>', 'to' => 'Você <' . $this->email . '>', 'subject' => 'Capacitação em Git & GitHub - Inscrito', 'text' => $this->name, 'html' => '<html style="width:500px"><style>html{width:500px; text-align:center;} img{width: 100%;} a{padding:5px 15px;}</style><img style="width:100%" src="http://www.infojr.com.br/git-github/assets/img/git-confirm.jpg"></img>
             <a style="padding:5px 15px" href="www.infojr.com.br">www.infojr.com.br</a>
             <a style="padding:5px 15px" href="www.facebook.com/infojrnews">/infojrnews</a>
             </html>'));
     return $result;
 }
All Usage Examples Of Mailgun\Mailgun::sendMessage