2

我有一个 apache James 邮件服务器设置,我想创建一个脚本来监听新邮件,然后与 Asterisk 服务器通信以呼叫用户电话号码并阅读邮件。我认为这是可能的,但找不到任何信息。我一直在使用 perl 脚本来完成其他任务,所以如果我可以用 perl 来做这件事,那就太好了。

提前致谢

4

3 回答 3

1

一个解决方案是设置一个 cron 作业来运行一个 perl 脚本,该脚本使用类似的东西Mail::POP3Client来检查新消息并使用 (maybe) 向 Asterisk 发送一些东西Asterisk::AGI。如果 CPAN 模块不能满足您的需求,您始终可以让 perl 脚本执行system调用以与能够检查 POP 或与 Asterisk 交互的命令行工具进行交互。

于 2011-04-15T17:48:35.380 回答
1

我想最好的方法是在java中编写一个Mailet并将其放入配置中以使其侦听根处理器中的所有邮件。

对于Apache James 3.0-beta5步骤将是这样的:

  1. 编写Mailet,即:

    import org.apache.mailet.*;
    public class myMailet extends GenericMailet {
      private String aParameter;
      @Override
      public void init(MailetConfig cfg) throws MessagingException {
        super.init(cfg);
        aParameter = getInitParameter("myNeatParameter"); // use this if you need to use some parameters specified inside the mailetcontainer.xml
      }
    
      @Override
      public void service(Mail email) throws MessagingException {
        doYourThingWith(email);
      }
    
      private void doYourThingWith(Mail email){
        // TODO something with the email
      }
    }
    
  2. 将 Mailet 构建到 jar 文件中

  3. 将生成的 jar 文件添加到 /conf/lib 文件夹

  4. 编辑 /conf/mailetcontainer.xml 文件,您将在其中添加:

    <mailet match="All" class="myMailet">
        <myNeatParameter>some value</myNeatParameter>
    </mailet>
    

    作为根处理器的子元素(或您认为合适的任何东西)。

  5. 重启詹姆斯

好吧,它不是脚本,但它是非常好的(即使不是最好的)解决方案。

于 2013-05-08T13:56:23.560 回答
0

您可以使用Mail::POP3Client来轮询邮箱中的消息。或者如果邮箱支持 IMAP 并且您想持续监控它,请使用 IMAP 模块,也许是Net::IMAP::Simple

我刚刚搜索了 [Asterisk Perl],第一页上出现了一个名为“如何编写 Perl AGI 应用程序”的指南。它描述了如何使用Asterisk::AGI模块通过 Perl 连接到 Asterisk 服务器。

最后,您需要一个文本转语音应用程序。我敢肯定有很多可用的。它们可能不会用 Perl 编写,但可能存在用于它们的 Perl 接口。

于 2011-06-16T14:07:07.030 回答