首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

mule3.4.0 Email透过smtp发送邮件信息

2013-08-26 
mule3.4.0 Email通过smtp发送邮件信息?? 实现的简单需求:??????????????? 1.控制台接收信息??????????????

mule3.4.0 Email通过smtp发送邮件信息

?? 实现的简单需求:

??????????????? 1.控制台接收信息
????????????????2.mule 发送邮件信息

mule的配置文件:

mule-email-config.xml

<?xml version="1.0" encoding="UTF-8"?><mule xmlns="http://www.mulesoft.org/schema/mule/core"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xmlns:spring="http://www.springframework.org/schema/beans"       xmlns:smtp="http://www.mulesoft.org/schema/mule/smtp"       xmlns:vm="http://www.mulesoft.org/schema/mule/vm"       xmlns:file="http://www.mulesoft.org/schema/mule/file"       xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio"       xmlns:email="http://www.mulesoft.org/schema/mule/email"       xsi:schemaLocation="       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd       http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd       http://www.mulesoft.org/schema/mule/smtp http://www.mulesoft.org/schema/mule/smtp/current/mule-smtp.xsd       http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd       http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd       http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd      http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd"><!-- 创建控制台对象 --><stdio:connector name="SystemStreamConnector"   promptMessage="please enter something:" /><!-- 创建邮件对象 --> <smtp:connector name="smtpConnector" />  <flow name="processed-orders"> <!--   <file:inbound-endpoint  encoding="UTF-8"   path="E:/out">   <file:file-to-byte-array-transformer />  </file:inbound-endpoint>  -->    <stdio:inbound-endpoint system="IN" />  <!-- 配置从控制台输入你的东西 -->  <smtp:outbound-endpoint host="smtp.126.com"    user="longgangbai" password="xxxxxxxx" port="25" from="longgangbai@126.com"   subject="processed order" to="longgangbai@sina.com">   <email:string-to-email-transformer />  </smtp:outbound-endpoint> </flow></mule>

?

测试代码:

import org.mule.api.MuleContext;import org.mule.api.context.MuleContextFactory;import org.mule.config.spring.SpringXmlConfigurationBuilder;import org.mule.context.DefaultMuleContextFactory;/** * <p> *   1.控制台接收信息 *   2.mule 发送邮件信息 * <p> * * 创建日期 2013-8-20<br> * @author  $Author$<br> * @version $Revision$ $Date$ * @since   3.0.0 */public class SendMailMain {        public static void main(String[] args) {        try {            System.setProperty("mule.verbose.exceptions","true");//          System.setProperty("java.endorsed.dirs","D:/android-workspace/MuleAxis/libs/endorsed");            System.out.println(System.getProperty("java.endorsed.dirs"));            String configFile = "mule-email-config.xml";            String[] configFileArr = new String[] {configFile };            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();            MuleContext muleContext = muleContextFactory                    .createMuleContext(new SpringXmlConfigurationBuilder(configFileArr));            muleContext.start();        } catch (Exception e) {            e.printStackTrace();        }    }}

?

热点排行