User Tools

Site Tools


Sidebar

Dokumentation

vortex:api:mailer

Mailer

The Mailer class handles incoming and outoing E-mail messages. It can connect to a mailserver using the IMAP or POP3 protocols to customizable server ports. Sending mail is currently done using the PHP mail() function which by default uses the local sendmail daemon to send mail.

Extends

Implements

Constants

MAILER_IMAPConstant for connecting using the IMAP protocol (default)
MAILER_POP3Constant for connecting using the POP3 protocol

Methods

Code Examples

Opening a Mailbox and fetching all the messages into an array of MailMessage instances:

try {
    $mailer = new Mailer( "myserver.mydomain.se", "myUsername", "myPassword" );
    $messages = $mailer->fetchMail();
} catch( Exception $e ) {
    die ( $e->getMessage() );
}
print_r( $messages );

Opening a mailbox, fetching the first ten messages and saving the first messages attachments to file:

try {
    $mailer = new Mailer( "myserver.mydomain.se", "myUserName", "myPassword" );
    $messages = $mailer->fetchMail( 1,10 );
} catch( Exception $e ) {
    die( $e->getMessage() );
}
foreach( $messages[0]->attachments AS $attachment ) {
    $attachment->saveFile();
}

Send a simple E-mail message:

$message = new MailMessage( "toaddress@mydomain.se", "Subject goes here","Body of message", "fromaddress@mydomain.se" );
$message->send();

Send an E-mail message with an attached file:

$message = new MailMessage( "toaddress@mydomain.se", "Subject goes here", "The text of the message", "fromaddress@mydomain.se" );
$message->attachments[] = new MailAttachment( "/path/to/attached/file.here" );
$message->send();
vortex/api/mailer.txt · Last modified: 2019/06/28 06:58 by hubbe