Skip to content

E-Mail APIs, POP3, IMAP, MailDir, SMTP support for the XP Framework

Notifications You must be signed in to change notification settings

xp-framework/mail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mail for XP

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

E-Mail APIs, POP3, IMAP, MailDir, SMTP support.

Creating an email

use peer\mail\{Message, InternetAddress};

$msg= new Message();
$msg->setFrom(new InternetAddress('[email protected]', 'Timm Friebe'));
$msg->addRecipient(TO, new InternetAddress('[email protected]', 'Foo Bar'));
$msg->addRecipient(CC, new InternetAddress('[email protected]', 'Timm Friebe'));
$msg->setHeader('X-Binford', '6100 (more power)');
$msg->setSubject('Hello world');
$msg->setBody('Testmail');

Sending email

use peer\mail\transport\{MailTransport, TransportException};

$smtp= new MailTransport();
try {
  $smtp->connect();
  $smtp->send($msg);
} catch (TransportException $e) {
  $e->printStackTrace();
}

$smtp->close();

Using an SMTP server

use peer\mail\transport\{SmtpConnection, TransportException};

$smtp= new SmtpConnection('esmtp://user:[email protected]:25/?auth=login');
try {
  $smtp->connect();
  $smtp->send($msg);
} catch (TransportException $e) {
  $e->printStackTrace();
}

$smtp->close();