Skip to content

Instantly share code, notes, and snippets.

@lolautruche
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lolautruche/24ef45a36a50b0bd8acb to your computer and use it in GitHub Desktop.
Save lolautruche/24ef45a36a50b0bd8acb to your computer and use it in GitHub Desktop.
EZP-23389: ezcMailComposer bug when sending e-mails with long name and Norwegian characters
<?php
/**
* Created by PhpStorm.
* User: lolautruche
* Date: 31/10/2014
* Time: 14:39
*/
namespace Acme\TestBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class EzcMailTestCommand extends ContainerAwareCommand
{
protected function configure()
{
$this->setName( 'test:ezcmail' );
}
public function execute( InputInterface $input, OutputInterface $output )
{
$from = [
'email' => 'no-reply@ez.no',
'name' => 'From name ØÆÅ test vive le sucre from ouais with a very long name which contains norwegian characters ÆØÅæøÅ'
];
$to = [
// Change with your e-mail address
'email' => 'jv@ez.no',
'name' => 'To ØÆÅ Name test même que c\'est pas drôle quand ça plante with a very long name which contains norwegian characters ÆØÅæøÅ'
];
$subject = 'Test øæå ØÆÅ subject test test test with a very long name which contains norwegian characters ÆØÅæøÅ that need to be handled correctly,';
$content = "Test of & content.";
$charset = 'utf-8';
$mail = new \ezcMailComposer();
$mail->charset = $charset;
$mail->subjectCharset = $charset;
$mail->from = new \ezcMailAddress( $from['email'], $from['name'], $charset );
$mail->addTo( new \ezcMailAddress( $to['email'], $to['name'], $charset ) );
$mail->subject = $subject;
$mail->plainText = $content;
$mail->build();
$transport = new \ezcMailMtaTransport();
$transport->send( $mail );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment