1700479686
public void sendMail(){
1700479687
1700479688
//增加邮件服务器信息
1700479689
1700479690
super.m.add(“Received:(sendmail);7 Nov 2009 04:14:44+0100”);
1700479691
1700479692
super.sendMail();
1700479693
1700479694
}
1700479695
1700479696
}
1700479697
1700479698
邮件和邮件服务器都有了,我们来看怎么发送邮件,如代码清单33-10所示。
1700479699
1700479700
代码清单33-10 场景类
1700479701
1700479702
public class Client{
1700479703
1700479704
public static void main(String[]args){
1700479705
1700479706
//创建一封TEXT格式的邮件
1700479707
1700479708
MailTemplate m=new HtmlMail(“a@a.com”,“b@b.com”,“外星人攻击地球了”,”
1700479709
1700479710
结局是外星人被地球人打败了!”);
1700479711
1700479712
//使用Postfix发送邮件
1700479713
1700479714
MailServer mail=new Postfix(m);
1700479715
1700479716
//发送邮件
1700479717
1700479718
mail.sendMail();
1700479719
1700479720
}
1700479721
1700479722
}
1700479723
1700479724
运行结果如下所示:
1700479725
1700479726
====正在发送的邮件信息====
1700479727
1700479728
发件人:a@a.com
1700479729
1700479730
收件人:b@b.com
1700479731
1700479732
邮件标题:外星人攻击地球了
1700479733
1700479734
邮件内容:
1700479735
[
上一页 ]
[ :1.700479686e+09 ]
[
下一页 ]