PHP code example of eustasy / browning

1. Go to this page and download the library: Download eustasy/browning library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eustasy / browning example snippets






return [
    // Mailgun API URL
    // Replace `<`example.com`>` with your verified Mailgun domain.
    'URL' => 'https://api.mailgun.net/v3/example.com',

    // Mailgun private API key.
    // Get it from "Domain Settings" > "Sending Keys" in your Mailgun dashboard.
    'Key' => '<your-mailgun-api-key>',

    'Default' => [
        'Regards' => 'Example Support',     // Sender display name
        'ReplyTo' => '[email protected]', // From / reply-to address
    ],

    // Optional reCAPTCHA v2 keys (see section 3).
    'Recaptcha' => [
        'SiteKey' => '<your-recaptcha-site-key>',
        'SecretKey' => '<your-recaptcha-secret-key>',
    ],
];



use Eustasy\Browning\Mailer;

$config = esult = $mailer->send(
    '[email protected]', // Required: recipient address
    'Message Subject',       // Required: subject line
    'Text or HTML body',     // Required: message body
    'Sender Name',           // Optional: overrides Default.Regards
    '[email protected]',  // Optional: overrides Default.ReplyTo
);

if ($result->success) {
    echo 'Email sent successfully.';
} else {
    echo 'Failed to send email: ' . $result->error;
}

$mailer = Mailer::fromArray($config, debug: true);

$mailer = new Mailer(
    apiUrl: 'https://api.mailgun.net/v3/example.com',
    apiKey: $secret,
    fromName: 'Example Support',
    fromAddress: '[email protected]',
);

use Eustasy\Browning\Mailer;
use Eustasy\Browning\Recaptcha;

$config = a-response'] ?? null,
    $_SERVER['REMOTE_ADDR'] ?? null, // Optional: user's IP address
);

if (! $check->success) {
    echo 'reCAPTCHA failed. Please go back and try again.';
} else {
    // reCAPTCHA passed — send the email.
    $result = Mailer::fromArray($config)->send(
        $_POST['dear'] ?? '',
        $_POST['subject'] ?? '',
        $_POST['message'] ?? '',
    );
}
sh
sudo apt-get install php-curl
sh
cp vendor/eustasy/browning/config/browning.default.php config/browning.php