本文整理汇总了PHP中htmlMimeMail::addHtmlImage方法的典型用法代码示例。如果您正苦于以下问题:PHP htmlMimeMail::addHtmlImage方法的具体用法?PHP htmlMimeMail::addHtmlImage怎么用?PHP htmlMimeMail::addHtmlImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htmlMimeMail
的用法示例。
在下文中一共展示了htmlMimeMail::addHtmlImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SendHtmlEmail
function SendHtmlEmail($plantilla, $variables, $subject, $destino, $origen = "presupuestos@pachecoforja.com", $imagenes = NULL, $imgdir = "img", $html = NULL)
{
require_once 'mail.php';
if (!$html) {
$smarty = SmartyInit();
$smarty->assign("variables", $variables);
$body = $smarty->fetch($plantilla);
} else {
$body = $html;
}
$mail = new htmlMimeMail();
// Definimos el html
$mail->setHtml($body);
// Comprobamos si hay imagenes embebidas en el correo
if ($imagenes != NULL) {
// Leemos todos los ficheros y los aadimos al correo
foreach ($imagenes as $imagen) {
$len = strlen($imagen);
$extension = substr($imagen, $len - 3, 3);
if ($extension == "gif") {
$tipo = "image/gif";
}
if ($extension == "jpg") {
$tipo = "image/jpg";
}
$fichero = $imgdir . "/" . $imagen;
$temp = $mail->getFile($fichero);
$mail->addHtmlImage($temp, $imagen, $tipo);
}
}
// Definimos las cabeceras de los mensajes
$mail->setReturnPath($origen);
$mail->setFrom($origen);
$mail->setSubject($subject);
$mail->setHeader('X-Mailer', 'Correo enviado por pachecoforja.com');
// Enviamos el correo
$result = $mail->send(array($destino), 'smtp');
if (!$result) {
return $mail->errors;
} else {
return true;
}
}
示例2:
$attachment = $mail->getFile('example.zip');
/*
* Get the contents of the example text/html files.
* Text/html data doesn't have to come from files,
* could come from anywhere.
*/
$text = $mail->getFile('example.txt');
$html = $mail->getFile('example.html');
/*
* Add the text, html and embedded images.
* The name (background.gif in this case)
* of the image should match exactly
* (case-sensitive) to the name in the html.
*/
$mail->setHtml($html, $text);
$mail->addHtmlImage($background, 'background.gif', 'image/gif');
/*
* This is used to add an attachment to
* the email. Due to above, the $attachment
* variable contains the example zip file.
*/
$mail->addAttachment($attachment, 'example.zip', 'application/zip');
/*
* Set the return path of the message
*/
$mail->setReturnPath('joe@example.com');
/**
* Set some headers
*/
$mail->setFrom('"Joe" <joe@example.com>');
$mail->setSubject('Test mail');