<?php

require_once 'tutorial_autoload.php';
// Create a new mail composer object
$mail = new ezcMailComposer();
// Specify the "from" mail address
$mail->from = new ezcMailAddress('*****@*****.**', 'John Doe');
// Add one "to" mail address (multiple can be added)
$mail->addTo(new ezcMailAddress('*****@*****.**', 'Cindy Doe'));
// Specify the subject of the mail
$mail->subject = "Example of an HTML email with attachments";
// Specify the plain text of the mail
$mail->plainText = "Here is the text version of the mail. This is displayed if the client can not understand HTML";
// Specify the html text of the mail
$mail->htmlText = "<html>Here is the HTML version of your mail with an image: <img src='file://path_to_image.jpg' /></html>";
// Add an attachment to the mail
$mail->addAttachment('path_to_attachment.file');
// Build the mail object
$mail->build();
// Create a new MTA transport object
$transport = new ezcMailMtaTransport();
// Use the MTA transport to send the created mail object
$transport->send($mail);
Ejemplo n.º 2
0
 public function testWalkPartsForStreamFile()
 {
     // create a temporary file
     $tmpFile = tempnam(sys_get_temp_dir(), "stream");
     file_put_contents($tmpFile, "content");
     // create mail instance
     $mail = new ezcMailComposer();
     $mail->addAttachment($tmpFile);
     $mail->build();
     // create the testing context
     $context = new ezcMailPartWalkContext(function ($ctx, $part) {
         $this->assertInstanceOf('ezcMailStreamFile', $part);
     });
     $context->filter = ['ezcMailStreamFile'];
     // test it
     $mail->walkParts($context, $mail);
     // remove the temporary file
     @unlink($tmpFile);
 }
Ejemplo n.º 3
0
<?php

require 'ezc-setup.php';
$mail = new ezcMailComposer();
// from and to addresses, and subject
$mail->from = new ezcMailAddress('*****@*****.**', 'John Doe');
$mail->addTo(new ezcMailAddress('*****@*****.**', 'Derick Rethans'));
$mail->subject = "Example of an HTML email with attachments";
// body: plain
$mail->plainText = "Here is the text version of the mail.";
// body: html
$mail->htmlText = <<<ENDHTML
<html>Here is the HTML version of your mail with an image: <img
src='file://{$dir}/consoletools-table.png'/></html>
ENDHTML;
// add an attachment
$mail->addAttachment("{$dir}/mail.php");
// send the mail
$transport = new ezcMailTransportSmtp('localhost', null, null, 2525);
$transport->send($mail);
Ejemplo n.º 4
0
 public function testContentDispositionSimpleAttach()
 {
     $mail = new ezcMailComposer();
     $mail->from = new ezcMailAddress('*****@*****.**');
     $mail->subject = "яверасфăîţâşåæøåöä";
     $mail->addTo(new ezcMailAddress('*****@*****.**'));
     $contentDisposition = new ezcMailContentDispositionHeader('attachment', 'яверасфăîţâşåæøåöä.jpg');
     $mail->plainText = 'xxx';
     $mail->addAttachment(dirname(__FILE__) . "/parts/data/fly.jpg", null, null, null, $contentDisposition);
     $mail->build();
     $msg = $mail->generate();
     $set = new ezcMailVariableSet($msg);
     $parser = new ezcMailParser();
     $mail = $parser->parseMail($set);
     $parts = $mail[0]->fetchParts();
     // for issue #13038, displayFileName was added to contentDisposition
     $contentDisposition->displayFileName = 'яверасфăîţâşåæøåöä.jpg';
     $this->assertEquals($contentDisposition, $parts[1]->contentDisposition);
 }