How to use getContentType method of mailer class

Best Atoum code snippet using mailer.getContentType

MailerTest.php

Source:MailerTest.php Github

copy

Full Screen

...76 public function testAddTextHtml()77 {78 $obj = Mailer::addTextHtml('Test message', '<b>test</b> message');79 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);80 $this->assertEquals('text/plain', $obj->getPart(0)->getContentType());81 $this->assertEquals('text/html', $obj->getPart(1)->getContentType());82 $this->assertEquals('Test message', $obj->getPart(0)->getContent());83 $this->assertEquals('<b>test</b> message', $obj->getPart(1)->getContent());84 }85 public function testAddTextHtmlFromHtml()86 {87 $obj = Mailer::addTextHtmlFromHtml('<b>test</b> message', 'Content :<br>--%content%--');88 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);89 $this->assertEquals('text/plain', $obj->getPart(0)->getContentType());90 $this->assertEquals('text/html', $obj->getPart(1)->getContentType());91 $this->assertEquals("Content :\r\n--test message--", $obj->getPart(0)->getContent());92 $this->assertEquals('Content :<br>--<b>test</b> message--', $obj->getPart(1)->getContent());93 }94 95 96 public function testAddTextHtmlFromText()97 {98 $obj = Mailer::addTextHtmlFromText('**test** message', 'Content :<br>--%content%--');99 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);100 $this->assertEquals('text/plain', $obj->getPart(0)->getContentType());101 $this->assertEquals('text/html', $obj->getPart(1)->getContentType());102 $this->assertEquals("Content :\r\n--**test** message--", $obj->getPart(0)->getContent());103 $this->assertEquals('Content :<br>--<b>test</b> message--', $obj->getPart(1)->getContent());104 }105 106 107 public function testAddAlternativeObject()108 {109 $obj = Mailer::addAlternativeObject(new MailTextPlainContent('textplain content'), new MailTextHtmlContent('html content'));110 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);111 $this->assertEquals('text/plain', $obj->getPart(0)->getContentType());112 $this->assertEquals('text/html', $obj->getPart(1)->getContentType());113 $this->assertEquals('textplain content', $obj->getPart(0)->getContent());114 $this->assertEquals('html content', $obj->getPart(1)->getContent());115 }116 117 118 public function testCreateText()119 {120 $obj = Mailer::createText('textplain content');121 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailTextPlainContent', $obj);122 $this->assertEquals('text/plain', $obj->getContentType());123 $this->assertEquals('textplain content', $obj->getContent());124 }125 126 127 public function testCreateHtml()128 {129 $obj = Mailer::createHtml('html content');130 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailTextHtmlContent', $obj);131 $this->assertEquals('text/html', $obj->getContentType());132 $this->assertEquals('html content', $obj->getContent());133 }134 135 136 public function testCreateEmbedding()137 {138 $obj = Mailer::createEmbedding(self::$_fatt, 'text/plain', 'cid-123');139 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailEmbedding', $obj);140 $this->assertEquals('text/plain', $obj->getContentType());141 }142 143 144 public function testCreateAttachment()145 {146 $obj = Mailer::createAttachment(self::$_fatt, 'attach.txt', 'text/plain');147 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailAttachment', $obj);148 $this->assertEquals('text/plain', $obj->getContentType());149 }150 151 152 public function testAddAttachment()153 {154 $obj = Mailer::addAttachment(new MailTextPlainContent('textplain content'), self::$_fatt, 'attach.txt', 'text/plain');155 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);156 $this->assertEquals('multipart/mixed', $obj->getContentType());157 $this->assertEquals( 158 "--" . $obj->getSeparator() . "\r\n" .159 "Content-Type: text/plain; charset=UTF-8\r\n" .160 "Content-Transfer-Encoding: quoted-printable\r\n" .161 "\r\n" .162 "textplain content\r\n" .163 "\r\n" .164 "--" . $obj->getSeparator() . "\r\n" .165 "Content-Type: text/plain;\r\n name=\"attach.txt\"\r\n" .166 "Content-Transfer-Encoding: base64\r\n" .167 "Content-Disposition: attachment;\r\n filename=\"attach.txt\"\r\n" .168 "\r\n" .169 self::$_fatt_content_b64 . "\r\n" .170 "\r\n" .171 "--" . $obj->getSeparator() . "--",172 173 $obj->getContent()174 );175 }176 177 178 public function testAddAttachments()179 {180 $obj = Mailer::addAttachments(new MailTextPlainContent('textplain content'), 181 [182 array('file'=>self::$_fatt, 'filename'=>'attach.txt', 'filetype'=>'text/plain'),183 array('file'=>self::$_fatt2, 'filename'=>'attach2.txt', 'filetype'=>'text/plain')184 ]185 );186 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);187 $this->assertEquals('multipart/mixed', $obj->getContentType());188 }189 190 191 public function testAddAttachmentObject()192 {193 $obj = Mailer::createAttachment(self::$_fatt, 'attach.txt', 'text/plain');194 $mail = Mailer::createText('textplain content');195 $matt = Mailer::addAttachmentObject($mail, $obj);196 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $matt);197 $this->assertEquals('multipart/mixed', $matt->getContentType());198 }199 200 201 public function testAddAttachmentObjects()202 {203 $obj = Mailer::createAttachment(self::$_fatt, 'attach.txt', 'text/plain');204 $obj2 = Mailer::createAttachment(self::$_fatt2, 'attach2.txt', 'text/plain');205 $mail = Mailer::createText('textplain content');206 $matt = Mailer::addAttachmentObjects($mail, [$obj, $obj2]);207 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $matt);208 $this->assertEquals('multipart/mixed', $matt->getContentType());209 }210 211 212 public function testAddEmbedding()213 {214 $obj = Mailer::addEmbedding(new MailTextPlainContent('textplain content'), self::$_fatt, 'text/plain', 'cid-123');215 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);216 $this->assertEquals('multipart/related', $obj->getContentType());217 $this->assertEquals(218 "--" . $obj->getSeparator() . "\r\n" .219 "Content-Type: text/plain; charset=UTF-8\r\n" .220 "Content-Transfer-Encoding: quoted-printable\r\n" .221 "\r\n" .222 "textplain content\r\n" .223 "\r\n" .224 "--" . $obj->getSeparator() . "\r\n" .225 "Content-Type: text/plain\r\n" .226 "Content-Transfer-Encoding: base64\r\n" .227 "Content-Disposition: inline;\r\n filename=\"cid-123\"\r\n" .228 "Content-ID: <cid-123>\r\n" .229 "\r\n" .230 self::$_fatt_content_b64 . "\r\n" .231 "\r\n" .232 "--" . $obj->getSeparator() . "--",233 234 $obj->getContent()235 ); 236 }237 238 239 public function testAddEmbeddings()240 {241 $obj = Mailer::addEmbeddings(new MailTextPlainContent('textplain content'), 242 [243 array('file'=>self::$_fatt, 'filetype'=>'text/plain', 'cid'=>'cid-123'),244 array('file'=>self::$_fatt2, 'filetype'=>'text/plain', 'cid'=>'cid-456')245 ]246 );247 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $obj);248 $this->assertEquals('multipart/related', $obj->getContentType());249 }250 251 252 public function testAddEmbeddingObject()253 {254 $obj = Mailer::createEmbedding(self::$_fatt, 'text/plain', 'cid-123');255 $mail = Mailer::createText('textplain content');256 $matt = Mailer::addEmbeddingObject($mail, $obj);257 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $matt);258 $this->assertEquals('multipart/related', $matt->getContentType());259 }260 261 262 public function testAddEmbeddingObjects()263 {264 $obj = Mailer::createEmbedding(self::$_fatt, 'text/plain', 'cid-123');265 $obj2 = Mailer::createEmbedding(self::$_fatt2, 'text/plain', 'cid-456');266 $mail = Mailer::createText('textplain content');267 $matt = Mailer::addEmbeddingObjects($mail, [$obj, $obj2]);268 $this->assertInstanceOf('Nettools\Mailing\MailPieces\MailMultipart', $matt);269 $this->assertEquals('multipart/related', $matt->getContentType());270 }271 272 273 public function testAddHeader()274 {275 $this->assertEquals('From: user@domain.tld', Mailer::addHeader('', 'From: user@domain.tld'));276 $this->assertEquals('From: user@domain.tld', Mailer::addHeader('From: user@domain.tld', ''));277 $this->assertEquals("From: user@domain.tld\r\nTo: other@domain.tld", Mailer::addHeader('From: user@domain.tld', 'To: other@domain.tld'));278 $this->assertEquals("From: other-user@domain.tld\r\nBcc: bcc-user@domain.tld", Mailer::addHeader("From: user@domain.tld\r\nBcc: bcc-user@domain.tld", 'From: other-user@domain.tld'));279 $this->assertEquals("Content-Type: multipart/mixed;\r\n boundary=\"xyz1234\"\r\nFrom: user@domain.tld", 280 Mailer::addHeader("Content-Type: multipart/mixed;\r\n boundary=\"xyz1234\"", 'From: user@domain.tld'));281 $this->assertEquals("Content-Type: text/plain; charset=UTF-8", 282 Mailer::addHeader("Content-Type: multipart/mixed;\r\n boundary=\"xyz1234\"", "Content-Type: text/plain; charset=UTF-8"));283 $this->assertEquals("Content-Type: multipart/mixed;\r\n boundary=\"abc5678\"",...

Full Screen

Full Screen

IMipPluginTest.php

Source:IMipPluginTest.php Github

copy

Full Screen

...54 $this->assertEquals('1.1', $message->getScheduleStatus());55 $this->assertEquals('Fellowship meeting', $mailMessage->getSubject());56 $this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());57 $this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());58 $this->assertEquals('text/calendar; charset=UTF-8; method=REQUEST', $mailMessage->getSwiftMessage()->getContentType());59 }60 public function testFailedDeliveryWithException() {61 $mailMessage = new \OC\Mail\Message(new \Swift_Message());62 /** @var Mailer | \PHPUnit\Framework\MockObject\MockObject $mailer */63 $mailer = $this->createMock(Mailer::class);64 $mailer->method('createMessage')->willReturn($mailMessage);65 $mailer->method('send')->willThrowException(new \Exception());66 /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject $logger */67 $logger = $this->createMock(Log::class);68 /** @var IRequest| \PHPUnit\Framework\MockObject\MockObject $request */69 $request = $this->createMock(IRequest::class);70 $plugin = new IMipPlugin($mailer, $logger, $request);71 $message = new Message();72 $message->method = 'REQUEST';73 $message->message = new VCalendar();74 $message->message->add('VEVENT', [75 'UID' => $message->uid,76 'SEQUENCE' => $message->sequence,77 'SUMMARY' => 'Fellowship meeting',78 ]);79 $message->sender = 'mailto:gandalf@wiz.ard';80 $message->recipient = 'mailto:frodo@hobb.it';81 $plugin->schedule($message);82 $this->assertEquals('5.0', $message->getScheduleStatus());83 $this->assertEquals('Fellowship meeting', $mailMessage->getSubject());84 $this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());85 $this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());86 $this->assertEquals('text/calendar; charset=UTF-8; method=REQUEST', $mailMessage->getSwiftMessage()->getContentType());87 }88 public function testFailedDelivery() {89 $mailMessage = new \OC\Mail\Message(new \Swift_Message());90 /** @var Mailer | \PHPUnit\Framework\MockObject\MockObject $mailer */91 $mailer = $this->createMock(Mailer::class);92 $mailer->method('createMessage')->willReturn($mailMessage);93 $mailer->method('send')->willReturn(['foo@example.net']);94 /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject $logger */95 $logger = $this->createMock(Log::class);96 $logger->expects(self::once())->method('error')->with('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => 'foo@example.net']);97 /** @var IRequest| \PHPUnit\Framework\MockObject\MockObject $request */98 $request = $this->createMock(IRequest::class);99 $plugin = new IMipPlugin($mailer, $logger, $request);100 $message = new Message();101 $message->method = 'REQUEST';102 $message->message = new VCalendar();103 $message->message->add('VEVENT', [104 'UID' => $message->uid,105 'SEQUENCE' => $message->sequence,106 'SUMMARY' => 'Fellowship meeting',107 ]);108 $message->sender = 'mailto:gandalf@wiz.ard';109 $message->recipient = 'mailto:frodo@hobb.it';110 $plugin->schedule($message);111 $this->assertEquals('5.0', $message->getScheduleStatus());112 $this->assertEquals('Fellowship meeting', $mailMessage->getSubject());113 $this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());114 $this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());115 $this->assertEquals('text/calendar; charset=UTF-8; method=REQUEST', $mailMessage->getSwiftMessage()->getContentType());116 }117 public function testDeliveryOfCancel() {118 $mailMessage = new \OC\Mail\Message(new \Swift_Message());119 /** @var Mailer | \PHPUnit\Framework\MockObject\MockObject $mailer */120 $mailer = $this->createMock(Mailer::class);121 $mailer->method('createMessage')->willReturn($mailMessage);122 $mailer->expects($this->once())->method('send');123 /** @var ILogger | \PHPUnit\Framework\MockObject\MockObject $logger */124 $logger = $this->createMock(Log::class);125 /** @var IRequest| \PHPUnit\Framework\MockObject\MockObject $request */126 $request = $this->createMock(IRequest::class);127 $plugin = new IMipPlugin($mailer, $logger, $request);128 $message = new Message();129 $message->method = 'CANCEL';130 $message->message = new VCalendar();131 $message->message->add('VEVENT', [132 'UID' => $message->uid,133 'SEQUENCE' => $message->sequence,134 'SUMMARY' => 'Fellowship meeting',135 ]);136 $message->sender = 'mailto:gandalf@wiz.ard';137 $message->recipient = 'mailto:frodo@hobb.it';138 $plugin->schedule($message);139 $this->assertEquals('1.1', $message->getScheduleStatus());140 $this->assertEquals('Cancelled: Fellowship meeting', $mailMessage->getSubject());141 $this->assertEquals(['frodo@hobb.it' => null], $mailMessage->getTo());142 $this->assertEquals(['gandalf@wiz.ard' => null], $mailMessage->getReplyTo());143 $this->assertEquals('text/calendar; charset=UTF-8; method=CANCEL', $mailMessage->getSwiftMessage()->getContentType());144 $this->assertEquals('CANCELLED', $message->message->VEVENT->STATUS->getValue());145 }146}...

Full Screen

Full Screen

Mail.php

Source:Mail.php Github

copy

Full Screen

...31 self::$embImg = $attachments;323334 35 add_filter( 'wp_mail_content_type', array( self::class, 'getContentType' ) );36 add_action( 'phpmailer_init', array( self::class, 'initMailer' ) );37 if ( ! empty( self::$fromMail ) ) {38 add_filter( 'wp_mail_from', array( self::class, 'setFromMail' ) );39 }40 if ( ! empty( self::$fromName ) ) {41 add_filter( 'wp_mail_from_name', array( self::class, 'setFromName' ) );42 }4344 45 $msg = ( ! empty( $htmlMessage ) ) ? $htmlMessage : $plainMessage;4647 48 if ( ! empty( $htmlMessage ) && empty( $plainMessage ) ) {49 50 foreach ( self::$embImg as $k => $v ) {51 $msg = str_replace( 'cid:' . $k, $v, $msg );52 }53 }5455 $return = wp_mail( $to, $subject, $msg, $headers, $attachments );5657 remove_filter( 'wp_mail_content_type', array( self::class, 'getContentType' ) );5859 remove_action( 'phpmailer_init', array( self::class, 'handleMultipart' ) );6061 if ( ! empty( self::$fromMail ) ) {62 remove_filter( 'wp_mail_from', array( self::class, 'setFromMail' ) );63 }64 if ( ! empty( self::$fromName ) ) {65 remove_filter( 'wp_mail_from_name', array( self::class, 'setFromName' ) );66 }6768 return $return;69 }7071 72 public static function getContentType() {73 if ( empty( self::$htmlMessage ) ) {74 return 'text/plain';75 }76 if ( empty( self::$plainMessage ) ) {77 return 'text/html';78 }7980 return 'multipart/alternative';81 }8283 84 public static function initMailer( $phpMailer ) {85 86 if ( self::getContentType() === 'multipart/alternative' ) {87 $phpMailer->AltBody = self::$plainMessage;8889 90 foreach ( self::$embImg as $k => $v ) {91 if ( ! empty( $v ) ) {92 $content = wp_remote_retrieve_body( wp_remote_get( $v ) );93 $phpMailer->AddStringEmbeddedImage( $content, $k );94 }95 }96 }979899 100 $phpMailer->CharSet = get_bloginfo( 'charset' ); ...

Full Screen

Full Screen

getContentType

Using AI Code Generation

copy

Full Screen

1require_once('class.phpmailer.php');2$mail = new PHPMailer();3$mail->IsSMTP();4$mail->Host = "smtp.gmail.com";5$mail->SMTPDebug = 2;6$mail->SMTPAuth = true;7$mail->SMTPSecure = "ssl";8$mail->Port = 465;

Full Screen

Full Screen

getContentType

Using AI Code Generation

copy

Full Screen

1require_once 'mailer.php';2$mailer = new Mailer();3$mailer->getContentType();4Content-Type: text/plain; charset="us-ascii"5Content-Type: text/html; charset="us-ascii"6Content-Type: multipart/mixed; boundary="=_nextpart_000_0000_01C6D3D0.7ABE1F90"

Full Screen

Full Screen

getContentType

Using AI Code Generation

copy

Full Screen

1require_once 'class.mailer.php';2$mailer = new Mailer();3echo $mailer->getContentType('1.php');4require_once 'class.mailer.php';5$mailer = new Mailer();6echo $mailer->getContentType('1.jpg');7require_once 'class.mailer.php';8$mailer = new Mailer();9echo $mailer->getContentType('1.pdf');10require_once 'class.mailer.php';11$mailer = new Mailer();12echo $mailer->getContentType('1.doc');13require_once 'class.mailer.php';14$mailer = new Mailer();15echo $mailer->getContentType('1.docx');16require_once 'class.mailer.php';17$mailer = new Mailer();18echo $mailer->getContentType('1.ppt');19require_once 'class.mailer.php';20$mailer = new Mailer();21echo $mailer->getContentType('1.pptx');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger getContentType code on LambdaTest Cloud Grid

Execute automation tests with getContentType on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful