本文整理汇总了PHP中PHPMailer::addEmbeddedImage方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::addEmbeddedImage方法的具体用法?PHP PHPMailer::addEmbeddedImage怎么用?PHP PHPMailer::addEmbeddedImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::addEmbeddedImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initMailFromSet
/**
* 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: addEmbeddedImage
/**
* {@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: testMultiEmbeddedImage
/**
* 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: addEmbeddedImage
/**
* 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: testIcal
/**
* 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);
}