VeldoraDocs

13. Mail & SMTP Transport

Veldora includes a clean, expressive Mailable system for sending HTML and plain-text emails via SMTP, Mailgun, or local log file transport.

Configuration

Configure your mail settings in .env:

.env
INI
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your_username
MAIL_PASSWORD=your_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_FROM_NAME="Veldora App"

Creating a Mailable

Terminal • bash
php veldora make:mail WelcomeEmail
php veldora make:mail OrderReceiptEmail

Defining a Mailable

example.php
PHP
// app/Mail/WelcomeEmail.php
namespace App\Mail;

use App\Models\User;
use Veldora\Framework\Mail\Mailable;

class WelcomeEmail extends Mailable
{
    public function __construct(
        public readonly User $user
    ) {}

    public function build(): static
    {
        return $this
            ->subject('Welcome to ' . config('app.name') . '!')
            ->from('hello@example.com', 'Veldora Team')
            ->view('emails.welcome', [
                'user'      => $this->user,
                'loginUrl'  => url('/login'),
            ]);
    }
}

Designing the Email View Template

Create the template at resources/views/emails/welcome.veldora.php:

template.veldora.php
HTML
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Welcome</title>
</head>
<body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
    <h2>Hello, &#123;&#123; $user->name &#125;&#125;!</h2>
    <p>Thank you for joining <strong>&#123;&#123; config('app.name') &#125;&#125;</strong>. We're excited to have you on board.</p>
    <p>
        <a href="&#123;&#123; $loginUrl &#125;&#125;" style="background: #8b5cf6; color: #fff; padding: 10px 20px; text-decoration: none; border-radius: 6px; display: inline-block;">
            Go to Your Dashboard
        </a>
    </p>
</body>
</html>

Sending & Queueing Emails

example.php
PHP
use App\Mail\WelcomeEmail;

// Send immediately via SMTP
mailer($user->email)->send(new WelcomeEmail($user));

// Queue for background delivery (requires queue:work running)
mailer($user->email)->queue(new WelcomeEmail($user));

// Send with CC and BCC
mailer($user->email)
    ->cc('admin@example.com')
    ->bcc('audit@example.com')
    ->send(new WelcomeEmail($user));


Veldora AI Developer Assistant Prompt

Paste this prompt at the start of any session with Claude, ChatGPT, Gemini, Cursor, or Copilot. It gives the model exact knowledge of Veldora's 51 CLI commands, 23 documentation modules, and prevents framework hallucinations.