禁用IPv6名称/地址支持:协议不支持的地址族

时间:2016-08-26 16:13:29

标签: cron symfony swiftmailer

我在Symfony3上遇到了标题中引用的错误并使用了自定义命令。有这个错误,但也没有发送邮件的事实。我找不到解决方案:
sendmail: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol
postdrop: warning: inet_protocols: disabling IPv6 name/address support: Address family not supported by protocol

以下是问题的核心:

我的命令

class poke2WeekUserCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('mr:poke-2-week-user')
            ->setDescription("Pokes users than havent't posted an advert for a while.")
            ->setHelp("Pokes users than havent't posted an advert for a while.")
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $cron = $this->getContainer()->get('mr_platform.cron');

        try {
            $cron->poke2WeekUser();
            $output->writeln('Ok !');
        } catch (\Exception $e) {
            $output->writeln('Error');
        }
    }
}

我的Cron课程

class Cron
{
  private $container;

  public function __construct($container){
    $this->container=$container;
  }

  public function poke2WeekUser(){
    $mailer=$this->container->get('mailer');
    $em=$this->container->get('doctrine.orm.entity_manager');
    $repUser=$em->getRepository('MRUserBundle:User');
    $users=$repUser->findAll();
    $ans='';
    foreach($users as $user){
        if((int)$user->getCreationDate()->diff(new \Datetime())->d==14&&!$user->getPerson()){
            $mail = \Swift_Message::newInstance()
               ->setSubject("Subscription and advert posting")
               ->setFrom(array('info@mamyroom.fr' => 'MamyRoom'))
               ->setTo($user->getEmail())
               ->setBody($this->container->get('templating')->render('MRPlatformBundle:Common/Mail:poke2WeekUser.html.twig',array('user'=>$user)), 'text/html')
            ;
            $mailer->send($mail);
            $ans.='Sent to '.$user->getUsername().PHP_EOL;
        }
    }
    return new Response($ans);
  }
}

我将通过注入容器和'use'语句。 我觉得有趣(而且很奇怪)是它在我的localhost上工作正常(错误发生在我的远程服务器上,有OVH):我认为OS X和Linux对这个问题有不同的行为?

我希望有人知道一点!提前致谢

0 个答案:

没有答案