本文整理汇总了PHP中PHPMailer::_mime_types方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::_mime_types方法的具体用法?PHP PHPMailer::_mime_types怎么用?PHP PHPMailer::_mime_types使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::_mime_types方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testMiscellaneous
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
public function testMiscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->addCustomHeader('SomeHeader: Some Value');
$this->Mail->clearCustomHeaders();
$this->Mail->clearAttachments();
$this->Mail->isHTML(false);
$this->Mail->isSMTP();
$this->Mail->isMail();
$this->Mail->isSendmail();
$this->Mail->isQmail();
$this->Mail->setLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->createHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
//Test pathinfo
$a = '/mnt/files/飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
$a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
}
示例2: test_Miscellaneous
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
function test_Miscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
$this->Mail->ClearCustomHeaders();
$this->Mail->ClearAttachments();
$this->Mail->IsHTML(false);
$this->Mail->IsSMTP();
$this->Mail->IsMail();
$this->Mail->IsSendMail();
$this->Mail->IsQmail();
$this->Mail->SetLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->CreateHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
$this->Mail->getFile(__FILE__);
}
示例3: testMiscellaneous
/**
* Miscellaneous calls to improve test coverage and some small tests.
*/
public function testMiscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->addCustomHeader('SomeHeader: Some Value');
$this->Mail->clearCustomHeaders();
$this->Mail->clearAttachments();
$this->Mail->isHTML(false);
$this->Mail->isSMTP();
$this->Mail->isMail();
$this->Mail->isSendmail();
$this->Mail->isQmail();
$this->Mail->setLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->createHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
$this->assertTrue($this->Mail->set('AllowEmpty', null), 'Null property set failed');
$this->assertTrue($this->Mail->set('AllowEmpty', false), 'Valid property set of null property failed');
//Test pathinfo
$a = '/mnt/files/飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_BASENAME), '飛兒樂 團光茫.mp3', 'Basename path element not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
$a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
$this->assertEquals(PHPMailer::filenameToType('abc.jpg?xyz=1'), 'image/jpeg', 'Query string not ignored in filename');
$this->assertEquals(PHPMailer::filenameToType('abc.xyzpdq'), 'application/octet-stream', 'Default MIME type not applied to unknown extension');
//Line break normalization
$eol = $this->Mail->LE;
$b1 = "1\r2\r3\r";
$b2 = "1\n2\n3\n";
$b3 = "1\r\n2\r3\n";
$this->Mail->LE = "\n";
$t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
$this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (1)');
$this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (2)');
$this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (3)');
$this->Mail->LE = "\r\n";
$t1 = "1{$this->Mail->LE}2{$this->Mail->LE}3{$this->Mail->LE}";
$this->assertEquals($this->Mail->fixEOL($b1), $t1, 'Failed to normalize line breaks (4)');
$this->assertEquals($this->Mail->fixEOL($b2), $t1, 'Failed to normalize line breaks (5)');
$this->assertEquals($this->Mail->fixEOL($b3), $t1, 'Failed to normalize line breaks (6)');
$this->Mail->LE = $eol;
}
示例4: get_mime_type_from_file_extension
/**
* @param $extension
*
* @return mixed
*/
public function get_mime_type_from_file_extension($extension)
{
global $phpmailer;
// (Re)create it, if it's gone missing
if (!$phpmailer instanceof PHPMailer) {
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer(true);
}
return $phpmailer->_mime_types($extension);
}
示例5: mail_mime_content_type
protected function mail_mime_content_type($filename)
{
return PHPMailer::_mime_types(array_pop(explode('.', $filename)));
}
示例6: enviar
/**
* Realiza el envio del email propiamente dicho
*/
function enviar()
{
require_once '3ros/phpmailer/class.phpmailer.php';
//Se obtiene la configuración del SMTP
$this->datos_configuracion = $this->get_datos_configuracion_smtp();
if (!isset($this->desde)) {
$this->desde = $this->datos_configuracion['from'];
}
//Construye y envia el mail
$mail = new PHPMailer();
$mail->IsSMTP();
if ($this->debug) {
$mail->SMTPDebug = true;
}
$mail->Timeout = $this->timeout;
$host = trim($this->datos_configuracion['host']);
if (isset($this->datos_configuracion['seguridad']) && trim($this->datos_configuracion['seguridad']) != '') {
if ($this->datos_configuracion['seguridad'] == 'ssl') {
if (!extension_loaded('openssl')) {
throw new toba_error('Para usar un SMTP con encriptación SSL es necesario activar la extensión "openssl" en php.ini');
}
}
$mail->set('SMTPSecure', $this->datos_configuracion['seguridad']);
}
if (isset($this->datos_configuracion['puerto']) && trim($this->datos_configuracion['puerto']) != '') {
$mail->set('Port', $this->datos_configuracion['puerto']);
}
$mail->Host = trim($host);
if (isset($this->datos_configuracion['auth']) && $this->datos_configuracion['auth']) {
$mail->SMTPAuth = true;
$mail->Username = trim($this->datos_configuracion['usuario']);
$mail->Password = trim($this->datos_configuracion['clave']);
}
$mail->From = $this->desde;
if (isset($this->datos_configuracion['nombre_from']) && trim($this->datos_configuracion['nombre_from']) != '') {
$this->desde_nombre = $this->datos_configuracion['nombre_from'];
}
if (isset($this->desde_nombre)) {
$mail->FromName = $this->desde_nombre;
} else {
$mail->FromName = $this->desde;
}
$mail->AddAddress($this->hacia);
foreach ($this->cc as $copia) {
$mail->AddCC($copia);
}
foreach ($this->bcc as $copia) {
$mail->AddBCC($copia);
}
if (isset($this->reply_to)) {
$mail->AddReplyTo($this->reply_to);
}
if (isset($this->confirmacion)) {
$mail->ConfirmReadingTo = $this->confirmacion;
}
$mail->Subject = $this->asunto;
$mail->Body = $this->cuerpo;
$mail->IsHTML($this->html);
$temporales = array();
$dir_temp = toba::proyecto()->get_path_temp();
foreach (array_keys($this->adjuntos) as $id_adjunto) {
$archivo = tempnam($dir_temp, 'adjunto');
file_put_contents($archivo, $this->adjuntos[$id_adjunto]['archivo']);
$temporales[] = $archivo;
$tipo = $mail->_mime_types($this->adjuntos[$id_adjunto]['tipo']);
$mail->AddAttachment($archivo, $this->adjuntos[$id_adjunto]['nombre'], 'base64', $tipo);
}
$exito = $mail->Send();
toba::logger()->debug("Enviado mail con asunto {$this->asunto} a {$this->hacia}");
//Elimina los temporales creado para los attachments
foreach ($temporales as $temp) {
unlink($temp);
}
if (!$exito) {
throw new toba_error("Imposible enviar mail. Mensaje de error: {$mail->ErrorInfo}");
}
}