📮
Mailwind
  • 🚀Getting started
    • 👋Introduction
    • 🔗Add a provider
  • 📚Documentation
    • 🎨Tailwind configuration
    • 🔡Dynamic Expressions
    • 📱Responsive
  • API parameters
  • Sendgrid
    • Send an email
      • cURL
      • .NET
      • NodeJS
      • PHP
  • AWS SES
    • Obtain your credentials
    • Send an email
      • cURL
      • .NET
      • NodeJS
      • PHP
  • Resend
    • Send an email
      • cURL
      • .NET
      • NodeJS
      • PHP
Powered by GitBook
On this page
  1. Sendgrid
  2. Send an email

PHP

To make the HTTP request easier, we use Guzzle for the example. Be free to use whatever you want

Find all parameters via this link: https://docs.sendgrid.com/api-reference/mail-send/mail-send

<?php
require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$url = "https://api.mailwind.io/v1/send/sendgrid/v3";

$data = [
    'layoutIdentifier' => '<<YOUR_LAYOUT_ID>>',
    'variables' => [],
    'code' => null,
    'personalizations' => [
        [
            'to' => [
                [
                    'email' => 'example@mailwind.io'
                ]
            ],
            'subject' => 'Hello from SendGrid!'
        ]
    ],
    'from' => [
        'email' => 'example@mailwind.io'
    ],
    'content' => [
        [
            'type' => 'text/plain',
            'value' => 'This is a test email sent via SendGrid.'
        ]
    ]
];

$headers = [
    "Content-Type" => "application/json",
    "Authorization" => "Bearer <<YOUR_API_KEY_HERE>>"
];

try {
    $response = $client->post($url, [
        'headers' => $headers,
        'json' => $data
    ]);

    $responseBody = $response->getBody();
    $decodedResponse = json_decode($responseBody, true);

    print_r($decodedResponse);
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
?>
PreviousNodeJSNextObtain your credentials

Last updated 1 year ago