---
title: PHP
description: Send emails via Reloop SMTP using PHPMailer in PHP.
---
> For the complete documentation index, see [llms-docs.txt](/llms-docs.txt) or the site index [llms.txt](/llms.txt). Full docs corpus: [llms-full-docs.txt](/llms-full-docs.txt). Prefer markdown URLs (append `.md`) for agent consumption. Product skill: [skill.md](/skill.md).


# PHPMailer SMTP Integration

Use the popular **PHPMailer** library to send transactional emails via Reloop.

[View complete runnable example on GitHub ↗](https://github.com/reloop-labs/reloop-examples/tree/main/smtp-php)

## Installation

Install PHPMailer via Composer:

```bash
composer require phpmailer/phpmailer
```

## Code Example

```php
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);

try {
    // Server settings
    $mail->isSMTP();
    $mail->Host       = 'smtp.reloop.sh';
    $mail->SMTPAuth   = true;
    $mail->Username   = 'reloop';
    $mail->Password   = getenv('RELOOP_API_KEY');
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
    $mail->Port       = 465;

    // Recipients
    $mail->setFrom('onboarding@reloop.sh', 'Onboarding');
    $mail->addAddress('delivered@resend.dev');

    // Content
    $mail->isHTML(true);
    $mail->Subject = 'Hello from PHPMailer';
    $mail->Body    = '<p>Congrats on sending your first email via Reloop SMTP using PHPMailer!</p>';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
```

<RelatedTopics>
  <RelatedTopic icon="smtp" title="SMTP Integration Overview" href="/docs/examples/smtp/introduction" />
  <RelatedTopic icon="siLaravel" title="Laravel Integration Guide" href="/docs/examples/php/laravel" />
  <RelatedTopic icon="siWordpress" title="WordPress SMTP Guide" href="/docs/integrations/wordpress" />
</RelatedTopics>
