PHP calls Mailgun to send an email and mailgun to send an email.
Summary: PHP calls Mailgun to send emails for your reference. The details are as follows:
This blog reference Mailgun official API github link: https://github.com/mailgun/mailgun-php
1. Mailgun depends on the composer tool. Therefore, it is very easy to install composer before using it. The following method shows how to install the composer tool:
curl -sS https://getcomposer.org/installer | php
2. the client of the Mailgun Api does not have a hard connection to Guzzle or any other library that sends HTTP messages, it uses an abstraction called HTTPlug, which can be flexibly selected for PSR-7 or HTTP clients. if you just want to start quickly, you should run the following command:
php composer.phar require mailgun/mailgun-php php-http/curl-client guzzlehttp/psr7
3. OK. You can use Mailgun to send emails only after the preceding steps are completed ~, For more information, see http://www.mailgun.com/official tutorial. The following is an example:
require 'vendor/autoload.php';use Mailgun\Mailgun;# First, instantiate the SDK with your API credentials and define your domain. $mg = new Mailgun("key-example");$domain = "example.com";# Now, compose and send your message.$mg->sendMessage($domain, array('from' => 'bob@example.com', 'to' => 'sally@example.com', 'subject' => 'The PHP SDK is awesome!', 'text' => 'It is so simple to send a message.'));
4. Remarks:
Of course, you can also send emails in html format.'Text' => $ textRewrite'Html' => $ htmlIf you want CC, BCC, and other functions in the same way as php, you only need to add 'cc' => 'Jack @ example.com 'to the array above ', 'bcc '=> 'jenny @ example.com', you can.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.