douyingmou1389 2015-07-05 16:44
浏览 42

如何用作曲家加载伊甸园?

I want to write an application that uses parts of the mailer part of the eden library.

I have required it via composer.json:

 "require": {
    "eden/mail": "^1.0",
    ...

It seems though that the library isn't autloaded properly, as the call to the eden via eden('mail')->smtp(...) function leads to:

PHP Fatal error:  Call to undefined function Kopernikus\MassMailer\Service\eden() in ~/src/massmailer/src/Kopernikus/MassMailer/Service/EdenMailerFactory.php on line 20

The quick setup guides only handles the case for the one-file approach via:

include('eden.php');
eden('debug')->output('Hello World'); //--> Hello World

I don't want to add a huge libary file and include it manually. The autoloading seems to works fine, I just have to use the class directly instead of going with the eden() function:

 use Eden\Mail\Smtp;

 YourClass
 {
     $smtp = new Smtp(
         $host, 
         $user, 
         $pass, 
         $port = NULL, 
         $ssl = false, 
         $tls = false
     );
 }

The autoloading seems to works fine basically, as I can use the class directly instead of going with the eden() function:

 use Eden\Mail\Smtp;

 YourClass
 {
     ...
     $smtp = new Smtp(
         $host, 
         $user, 
         $pass, 
         $port, 
         $ssl, 
         $tls
     );
 }

Yet then I get weird errors like when trying to send a mail.

[Eden\Core\Exception]                                                             
  Both Physical and Virtual method Eden\Mail\Smtp->_getPlainBody() 

I want to go the composer route.

It seems I have to include a file via include-path option or add someting to the autoload, yet I am unsure.

How to load eden mailer component the composer way?

  • 写回答

2条回答 默认 最新

  • dongzhi8984 2015-07-05 19:31
    关注

    Not a solution to the question direclty, but I managed to circumvent the issue by switching to "nette/mail".

    composer remove eden/mail
    composer require nette/mail
    

    The SMTP worked fine for me via:

        $options = [
            'host'     => 'smtp.gmail.com',
            'username' => 'YOUR_ACCOUNT',
            'password' => 'YOUR_PASSWORD',
            'secure'   => 'ssl',
        ];        
        $mailer = new Nette\Mail\MessageSmtpMailer($options);
    
        $message = new Nette\Mail\Message();
        $message->setFrom('my.mail@gmail.com');
        $message->setBody('fnord');
        $message->setSubject('foo');
        $message->addTo(sendTo@gmail.com);
    
        $mailer->send($message);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器