piyo2/mail

PHP mail composer

Maintainers

Details

github.com/piyo2/mail

Source

Issues

Installs: 22

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/piyo2/mail

v1.0.2 2022-10-18 01:03 UTC

This package is auto-updated.

Last update: 2025-10-06 05:50:53 UTC


README

A PHP mail composer.

Installation

composer require piyo2/mail

Usage

<?php
$mail = new \piyo2\mail\Mail();

// Set sender
$mail->from('sender@example.com', 'John Doe');

// Set subject
$mail->subject('Hello World');

// Set body
$mail->message('Hello World');

// Set HTML body
$mail->htmlMessage('<h1>Hello World</h1>');

// Add header
$mail->header('X-My-Header', 'My Header');

// Add attachment
$attachment = \piyo2\mail\Attachment::fromFile('/path/to/file', 'text/plain', 'file.txt');
$mail->attach($attachment);

$other = \piyo2\mail\Attachment::fromContent('Hello World', 'text/plain', 'hello.txt');
$mail->attach($other);

// Send mail
$mail->send('recipient@example.com');