/** * Tests CharSet and Unicode -> ASCII conversions for addresses with IDN. */ public function testConvertEncoding() { if (!$this->Mail->idnSupported()) { $this->markTestSkipped('intl and/or mbstring extensions are not available'); } $this->Mail->clearAllRecipients(); $this->Mail->clearReplyTos(); // This file is UTF-8 encoded. Create a domain encoded in "iso-8859-1". $domain = '@' . mb_convert_encoding('françois.ch', 'ISO-8859-1', 'UTF-8'); $this->Mail->addAddress('test' . $domain); $this->Mail->addCC('test+cc' . $domain); $this->Mail->addBCC('test+bcc' . $domain); $this->Mail->addReplyTo('test+replyto' . $domain); // Queued addresses are not returned by get*Addresses() before send() call. $this->assertEmpty($this->Mail->getToAddresses(), 'Bad "to" recipients'); $this->assertEmpty($this->Mail->getCcAddresses(), 'Bad "cc" recipients'); $this->assertEmpty($this->Mail->getBccAddresses(), 'Bad "bcc" recipients'); $this->assertEmpty($this->Mail->getReplyToAddresses(), 'Bad "reply-to" recipients'); // Clear queued BCC recipient. $this->Mail->clearBCCs(); $this->buildBody(); $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo); // Addresses with IDN are returned by get*Addresses() after send() call. $domain = $this->Mail->punyencodeAddress($domain); $this->assertEquals([['test' . $domain, '']], $this->Mail->getToAddresses(), 'Bad "to" recipients'); $this->assertEquals([['test+cc' . $domain, '']], $this->Mail->getCcAddresses(), 'Bad "cc" recipients'); $this->assertEmpty($this->Mail->getBccAddresses(), 'Bad "bcc" recipients'); $this->assertEquals(['test+replyto' . $domain => ['test+replyto' . $domain, '']], $this->Mail->getReplyToAddresses(), 'Bad "reply-to" addresses'); }