addEmbeddedImage() public method

This can include images, sounds, and just about any other document type. These differ from 'regular' attachments in that they are intended to be displayed inline with the message, not just attached for download. This is used in HTML messages that embed the images the HTML refers to using the $cid value.
public addEmbeddedImage ( string $path, string $cid, string $name = '', string $encoding = 'base64', string $type = '', string $disposition = 'inline' ) : boolean
$path string Path to the attachment.
$cid string Content ID of the attachment; Use this to reference the content when using an embedded image in HTML.
$name string Overrides the attachment name.
$encoding string File encoding (see $Encoding).
$type string File MIME type.
$disposition string Disposition to use
return boolean True on successfully adding an attachment
コード例 #1
5
ファイル: Mailer.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Inner mailer initialization from set variables
  *
  * @return void
  */
 protected function initMailFromSet()
 {
     $this->mail->setLanguage($this->get('langLocale'), $this->get('langPath'));
     $this->mail->CharSet = $this->get('charset');
     $this->mail->From = $this->get('from');
     $this->mail->FromName = $this->get('fromName') ?: $this->get('from');
     $this->mail->Sender = $this->get('from');
     $this->mail->clearAllRecipients();
     $this->mail->clearAttachments();
     $this->mail->clearCustomHeaders();
     $emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
     foreach ($emails as $email) {
         $this->mail->addAddress($email);
     }
     $this->mail->Subject = $this->get('subject');
     $this->mail->AltBody = $this->createAltBody($this->get('body'));
     $this->mail->Body = $this->get('body');
     // add custom headers
     foreach ($this->get('customHeaders') as $header) {
         $this->mail->addCustomHeader($header);
     }
     if (is_array($this->get('images'))) {
         foreach ($this->get('images') as $image) {
             // Append to $attachment array
             $this->mail->addEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
         }
     }
 }
コード例 #2
4
ファイル: oxemail.php プロジェクト: Crease29/oxideshop_ce
 /**
  * {@inheritdoc}
  */
 public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream', $disposition = 'inline')
 {
     $this->_aAttachments[] = array($path, basename($path), $name, $encoding, $type, false, $disposition, $cid);
     return parent::addEmbeddedImage($path, $cid, $name, $encoding, $type, $disposition);
 }
コード例 #3
3
ファイル: phpmailerTest.php プロジェクト: jbs321/portfolio
 /**
  * An embedded attachment test.
  */
 public function testMultiEmbeddedImage()
 {
     $this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="' . 'cid:my-attach">' . 'Here is an image!</a>';
     $this->Mail->Subject .= ': Embedded Image + Attachment';
     $this->Mail->isHTML(true);
     if (!$this->Mail->addEmbeddedImage(realpath($this->INCLUDE_DIR . '/examples/images/phpmailer.png'), 'my-attach', 'phpmailer.png', 'base64', 'image/png')) {
         $this->assertTrue(false, $this->Mail->ErrorInfo);
         return;
     }
     if (!$this->Mail->addAttachment(__FILE__, 'test.txt')) {
         $this->assertTrue(false, $this->Mail->ErrorInfo);
         return;
     }
     $this->buildBody();
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
 }
コード例 #4
2
 /**
  * Adds an embedded attachment (check phpmail documentation for more details)
  *
  * @param string $sFullPath Path to the attachment.
  * @param string $sCid      Content ID of the attachment. Use this to identify the Id for accessing the image in an HTML form.
  * @param string $sAttFile  Overrides the attachment name.
  * @param string $sEncoding File encoding (see $Encoding).
  * @param string $sType     File extension (MIME) type.
  *
  * @return bool
  */
 public function addEmbeddedImage($sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream')
 {
     $this->_aAttachments[] = array($sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid);
     return parent::addEmbeddedImage($sFullPath, $sCid, $sAttFile, $sEncoding, $sType);
 }
コード例 #5
1
ファイル: phpmailerTest.php プロジェクト: ahmedash95/Lily
 /**
  * iCal event test.
  */
 public function testIcal()
 {
     $this->Mail->Body = 'This is the <strong>HTML</strong> part of the email.';
     $this->Mail->AltBody = 'This is the text part of the email.';
     $this->Mail->Subject .= ': iCal';
     $this->Mail->isHTML(true);
     $this->buildBody();
     require_once '../extras/EasyPeasyICS.php';
     $ICS = new EasyPeasyICS('PHPMailer test calendar');
     $ICS->addEvent(strtotime('tomorrow 10:00 Europe/Paris'), strtotime('tomorrow 11:00 Europe/Paris'), 'PHPMailer iCal test', 'A test of PHPMailer iCal support', 'https://github.com/PHPMailer/PHPMailer');
     $this->Mail->Ical = $ICS->render(false);
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
     $this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="cid:my-attach">' . 'Here is an image!</a>.';
     $this->Mail->AltBody = 'This is the text part of the email.';
     $this->Mail->Subject .= ': iCal + inline';
     $this->Mail->isHTML(true);
     $this->Mail->addEmbeddedImage('../examples/images/phpmailer.png', 'my-attach', 'phpmailer.png', 'base64', 'image/png');
     $this->buildBody();
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
 }