- 浏览: 1130558 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (411)
- Java Foundation (41)
- AI/机器学习/数据挖掘/模式识别/自然语言处理/信息检索 (2)
- 云计算/NoSQL/数据分析 (11)
- Linux (13)
- Open Source (12)
- J2EE (52)
- Data Structures (4)
- other (10)
- Dev Error (41)
- Ajax/JS/JSP/HTML5 (47)
- Oracle (68)
- FLEX (19)
- Tools (19)
- 设计模式 (4)
- Database (12)
- SQL Server (9)
- 例子程序 (4)
- mysql (2)
- Web Services (4)
- 面试 (8)
- 嵌入式/移动开发 (18)
- 软件工程/UML (15)
- C/C++ (7)
- 架构Architecture/分布式Distributed (1)
最新评论
-
a535114641:
LZ你好, 用了这个方法后子页面里的JS方法就全不能用了呀
页面局部刷新的两种方式:form+iframe 和 ajax -
di1984HIT:
学习了,真不错,做个记号啊
Machine Learning -
赵师傅临死前:
我一台老机器,myeclipse9 + FB3.5 可以正常使 ...
myeclipse 10 安装 flash builder 4.6 -
Wu_Jiang:
触发时间在将来的某个时间 但是第一次触发的时间超出了失效时间, ...
Based on configured schedule, the given trigger will never fire. -
cylove007:
找了好久,顶你
Editable Select 可编辑select
SMTP POP3的区别到底是什么?
http://www.wisegeek.com/what-is-the-difference-between-smtp-and-pop.htm
引用
There are two standards currently used for most e-mail sent today. SMTP stands for simple mail transfer protocol. POP is an acronym Post Office Protocol. Though it may sound confusing, the difference is not hard to understand. POP is a protocol for storage of email. SMTP is a protocol for sending and receiving.
要站在邮件服务器的角度理解邮件协议:
对server来说,smtp就是用来收/发邮件的协议;而pop(3是其版本)是用来存储邮件的协议。
How email works (MTA, MDA, MUA):
http://en.kioskea.net/contents/courrier-electronique/fonctionnement-mta-mua.php3
引用
简而言之:
MTA(Mail Transport Agent) 就是常说的 SMTP Server
MDA(Mail Delivery Agent) 就是常说的 POP server or IMAP server (depending on which protocol is used.)
MUA(Mail User Agent) 就是常说的 email client(邮件客户端),如Mozilla Thunderbird, Microsoft Outlook, Lotus Notes等。
MTA(Mail Transport Agent) 就是常说的 SMTP Server
MDA(Mail Delivery Agent) 就是常说的 POP server or IMAP server (depending on which protocol is used.)
MUA(Mail User Agent) 就是常说的 email client(邮件客户端),如Mozilla Thunderbird, Microsoft Outlook, Lotus Notes等。
SMTP Server reply codes:
http://www.greenend.org.uk/rjk/tech/smtpreplies.html
Email Headers 详解:
http://support.google.com/mail/answer/29436?hl=en
headers 中的 From / Sender / Return-Path 的区别是什么?
http://stackoverflow.com/questions/3835065/smtp-e-mail-headers-return-path-vs-sender-vs-from
邮件反垃圾之 MX SPF DKIM DMARC:
http://m.udpwork.com/item/4690.html
MX (Mail eXchanger):
http://support.google.com/a/bin/answer.py?hl=cn&hlrm=zh-Hant&answer=48090
引用
邮件交换 (MX) 记录将域的电子邮件导向至服务器。一个域可定义多个 MX 记录,每个记录都有不同的优先级,数字越小表示优先级越高。如果邮件通过第一优先级记录无法递送,则采用第二优先级,以此类推。
DKIM (DomainKeys Identified Mail):
http://support.google.com/a/bin/answer.py?hl=cn&hlrm=en&answer=174124
引用
垃圾邮件发件人可以伪造邮件上的“发件人”地址,使垃圾邮件看起来好像来自某个受信任的其他的域、地址。为了防止这种滥用行为,使用 DKIM 技术可以将数字“签名”添加到从发件人所在域发送的邮件的 Email Headers 中。收件人可以通过检查域签名来验证该邮件是否确实来自于发件人所在的域,且中途没有被更改过。
SPF (Sender Policy Framework):
http://blog.csdn.net/blade2001/article/details/8509203
引用
SPF是为了防范垃圾邮件而提出来的一种DNS记录类型,它是一种TXT类型的记录,它用于登记某个域名拥有的用来外发邮件的所有IP地址。当你定义了你的domain name的SPF记录之后,接收邮件方会根据你的SPF记录来确定连接过来的IP地址是否被包含在SPF记录里面,如果在,则认为是一封正确的邮件,否则则认为是一封伪造的邮件。
DMARC (Domain-based Message Authentication, Reporting & Conformance)
http://blog.163.com/pandalove@126/blog/static/9800324520123147328334/ or
http://www.mail163.cn/anti-spam/DMARC-Technical.html
引用
由 Paypal,Google,Microsoft, Yahoo 等公司联手成立的,基于现有的 DKIM 和 SPF 两大主流电子邮件安全协议的反垃圾邮件技术,目前尚未成熟,仍处于草案阶段。
工具:
通过分析 Email Header,找到邮件最初被哪个 SMTP Server 发出来(它的域名及IP地址;在收件服务器对该原始发件SMTP Server做SPF时,会需要用到它的IP地址):
http://whatismyipaddress.com/trace-email
关于 gmail 的 mailed-by & signed-by:
http://blog.wordtothewise.com/2011/06/gmail-shows-authentication-data-to-the-recipient/
Java Mail
Session,Transport,(under Transport)Socket Connection 关系:
A Session only holds configuration information.
A Transport corresponds to a single connection.
https://forums.oracle.com/forums/thread.jspa?threadID=2435565
引用
You can definitely share a JavaMail Session object between threads since the Session contains
only configuration information.
Sharing a JavaMail Transport object between threads is not a good idea. A Transport represents
a connection to the mail server and only one thread can use the connection at a time.
If you open a Transport connection and keep it around for a long time without using it, the server
may close the connection. Servers want you to open connections only when you're using them.
Servers also don't want you to abuse a connection and so may close a connection if they think
you're using it too much (e.g., to send spam). You can't prevent either of these actions, but you
can detect that the connection has been closed and open a new connection when you need it.
http://stackoverflow.com/questions/14238149/whats-the-relation-between-session-and-smtp-connection-in-javamail
only configuration information.
Sharing a JavaMail Transport object between threads is not a good idea. A Transport represents
a connection to the mail server and only one thread can use the connection at a time.
If you open a Transport connection and keep it around for a long time without using it, the server
may close the connection. Servers want you to open connections only when you're using them.
Servers also don't want you to abuse a connection and so may close a connection if they think
you're using it too much (e.g., to send spam). You can't prevent either of these actions, but you
can detect that the connection has been closed and open a new connection when you need it.
Session/Transport 与 Thread safety:
http://stackoverflow.com/questions/12732584/threadsafety-in-javamail
引用
Admittedly the thread safety rules for JavaMail are not well documented, but hopefully they mostly match what you would expect.
Multiple threads can use a Session.
Since a Transport represents a connection to a mail server, and only a single thread can use the connection at a time, a Transport will synchronize access from multiple threads to maintain thread safety, but you'll really only want to use it from a single thread.
Similarly, a Store can be used by multiple threads, but access to the underlying connection will be synchronized and single threaded.
A Message should only be modified by a single thread at a time, but multiple threads should be able to read a message safely (although it's not clear why you would want to do that).
https://forums.oracle.com/forums/thread.jspa?threadID=1587336&tstart=105Multiple threads can use a Session.
Since a Transport represents a connection to a mail server, and only a single thread can use the connection at a time, a Transport will synchronize access from multiple threads to maintain thread safety, but you'll really only want to use it from a single thread.
Similarly, a Store can be used by multiple threads, but access to the underlying connection will be synchronized and single threaded.
A Message should only be modified by a single thread at a time, but multiple threads should be able to read a message safely (although it's not clear why you would want to do that).
引用
First, don't use Session.getDefaultInstance, use Session.getInstance.
A Session encapsulates configuration information. You can safely shared
a Session between threads, assuming they all need the same configuration.
Sharing an SMTP Transport between threads is probably a bad idea.
While the Transport has synchronized methods to protect its own state,
you might not want one thread to wait until another thread is completely
done sending a message. It may depend on whether the main job of each
thread is to send a message, or whether the threads are doing lots of other
work and sending a message is just incidental and infrequent.
A Session encapsulates configuration information. You can safely shared
a Session between threads, assuming they all need the same configuration.
Sharing an SMTP Transport between threads is probably a bad idea.
While the Transport has synchronized methods to protect its own state,
you might not want one thread to wait until another thread is completely
done sending a message. It may depend on whether the main job of each
thread is to send a message, or whether the threads are doing lots of other
work and sending a message is just incidental and infrequent.
JavaMail Official Site:
http://www.oracle.com/technetwork/java/javamail/index.html
JAVAMAIL API FAQ:
http://www.oracle.com/technetwork/java/javamail/faq/index.html
JavaMail API Design Specification:
http://www.oracle.com/technetwork/java/javamail-1-149769.pdf
JavaMail API Javadocs:
http://javamail.kenai.com/nonav/javadocs/
Sending an Email using the JavaMail API:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/javamail/javamail.html
Fundamentals of the JavaMail API:
http://www.digilife.be/quickreferences/pt/fundamentals%20of%20the%20javamail%20api.pdf
JavaMail深入体验开发二: JavaMail的体系结构及发送复杂邮件:
http://blog.csdn.net/t12x3456/article/details/7636701
引用
JavaMail API按其功能划分通常可分为如下三大类:
创建和解析邮件内容的API :Message类是创建和解析邮件的核心API,它的实例对象代表一封电子邮件。
发送邮件的API:Transport类是发送邮件的核心API类,它的实例对象代表实现了某个邮件发送协议的邮件发送对象,例如SMTP协议。
接收邮件的API:Store类是接收邮件的核心API类,它的实例对象代表实现了某个邮件接收协议的邮件接收对象,例如POP3协议。
Session类
Session类用于定义整个应用程序所需的环境信息,以及收集客户端与邮件服务器建立网络连接的会话信息,如邮件服务器的主机名、端口号、采用的邮件发送和接收协议等。Session对象根据这些信息构建用于邮件收发的Transport和Store对象,以及为客户端创建Message对象时提供信息支持。
http://www.coderanch.com/how-to/java/JavaEnterpriseEditionFaq
spring 的 javamail 封装:
http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mail.html
AOP 101: Speeding up Spring’s JavaMailSenderImpl with AOP:
http://springinpractice.com/2008/11/15/aop-101-speeding-up-springs-javamailsenderimpl-with-aop/#
关于smtp发送的 mail.smtp.timeout 和 mail.smtp.connectiontimeout:
https://forums.oracle.com/forums/thread.jspa?messageID=6660679
引用
The java socket api makes a distinction between the timeout for opening a socket connection and the timeout for any read/write operation on that socket after it has been opened.
So mail.smtp.connectiontimeout is the timeout (in milliseconds) for establishing the SMTP connection and mail.smtp.timeout is the timeout (also milliseconds) for sending the mail messages. You can start by setting them both to the same reasonable value depending on how slow your servers tend to be and then tune them for the best user experience.
transport.close()时会用到mail.smtp.timeout。
So mail.smtp.connectiontimeout is the timeout (in milliseconds) for establishing the SMTP connection and mail.smtp.timeout is the timeout (also milliseconds) for sending the mail messages. You can start by setting them both to the same reasonable value depending on how slow your servers tend to be and then tune them for the best user experience.
这两个 timeout 的默认值都是无限大(Default is infinite timeout).
关于JavaMail v1.4.3+ 的 SMTPTransport.isConnected() 与 mail.smtp.noop.strict(noopStrict,默认true)的关系:
https://forums.oracle.com/forums/thread.jspa?threadID=1556610
引用
JavaMail uses the SMTP NOOP command to determine if the connection is still alive and surprisingly some servers don't return the correct response code to that command. We used to be very lax about the expected response code but as more and more servers started returning the expected response code we tightened this up. If you're using an older server that still returns the wrong response code, you might need to set "mail.smtp.noop.strict" to "false".
疑问:
prop配置的mail.from、mail.smtp.from,及MimeMessage本身的setFrom()之from的关系是什么?
为什么配置了mail.from或mail.smtp.from,MimeMessage本身还必须通过调用setFrom()设置from(不设置的话收件人收到的email message在收件箱里看不到from信息的)?
解答:
http://javamail.kenai.com/nonav/javadocs/com/sun/mail/smtp/SMTPMessage.html#setEnvelopeFrom(java.lang.String)
引用
Set the From address to appear in the SMTP envelope. Note that this is different than the From address that appears in the message itself. The envelope From address is typically used when reporting errors. See RFC 821 for details.
If set, overrides the mail.smtp.from property.
http://www.oracle.com/technetwork/java/faq-135477.html#smtpfrom
If set, overrides the mail.smtp.from property.
http://stackoverflow.com/questions/1782659/how-to-set-the-return-path-to-an-email-address-other-than-sender-address-using-j
message本身的from 和 mail.from/mail.smtp.from是完全不一样的;message本身的from是邮件的收件人看到的“邮件是由谁发的”;而mail.from/mail.smtp.from,则是邮件被退回(bounced)等时,被退到的邮箱地址。
另外注意message的replyTo是设置“回复地址”的;message的replyTo如果未设置,默认就使用其from;如果希望回复邮箱和发件邮箱不一样,可以设置该属性。
mail.xxx和mail.protocol.xxx之间,则是在该特定protocol下,后者会将前者重写掉的关系。
另外记得在prop里或者设置"mail.user" and "mail.host",或者设置"mail.from",不可以三个都不设置:
http://www.oracle.com/technetwork/java/faq-135477.html#securityManager
引用
Alternatively, the application can use its own Properties object and be sure to set the "mail.from" property or the "mail.user" and "mail.host" properties (see the InternetAddress.getLocalAddress() method).
connection hangs by SMTP Server:
http://stackoverflow.com/questions/8265933/continuous-email-server-connection-using-java-mail-api
use Spring + JNDI acquire javamail Session:
http://stackoverflow.com/questions/12257304/javamailsender-returning-null-pointer-exception
发表评论
-
Lucene & Solr
2013-05-07 17:30 2370Params of solr query (参见 solrj ... -
Continuous Integration Server:Jenkins & Hudson
2013-04-15 16:15 1422Jenkins: http://jenkins-ci.org/ ... -
Spring Integration
2013-03-26 16:52 3005Spring Integration Reference ... -
高可用与负载均衡:Haproxy(or lVS) + keepalived
2013-01-29 20:35 3111sources: Setting Up A High ... -
Spring Batch: 大数据量批量并行处理框架
2013-01-11 16:19 4804Spring Batch Documentati ... -
AOP: Aspect Oriented Programming
2013-01-06 11:13 2750The AspectJ Programming Gu ... -
Performance & Load test tool : JMeter
2012-12-18 14:28 1248Official: http://jmeter.apa ... -
rabbitmq & spring amqp
2012-12-04 00:09 8660My main AMQP post on blogger ... -
未完 Spring MVC
2012-11-15 22:41 2067Annotations for Http pa ... -
JUnit 单元测试
2012-10-30 12:27 2525测试的分类: http://s ... -
Hibernate
2011-08-02 11:48 1128Hibernate缓存: 一级缓存的生命周期和session的 ... -
Maven Repository Management & Nexus
2011-07-30 11:39 1368Why do I need a Repositor ... -
XStream
2011-07-13 00:18 1331XStream 内置 Converters: http://x ... -
Hibernate注解: 联合主键:@IdClass vs @EmbeddedId
2011-07-12 21:01 15313Hibernate Annotations -> 2.2 ... -
Struts2 Tag 标签
2011-05-04 00:43 1598struts2 OGNL 中的#、%等符号的区别: Apach ... -
Spring
2011-04-07 19:10 2841Spring API & Reference: htt ... -
iBATIS cacheModel 缓存
2011-04-07 14:29 1296http://ibatis.apache.org/docs/d ... -
Template Engine: FreeMarker & Velocity
2011-01-16 22:56 4054FreeMarker http://freemar ... -
Struts2 标签 <s:url>中添加多个<s:param>的奇怪问题 待整理
2011-01-14 13:27 1862问题描述(我的回复): http://went3456.ite ... -
J2EE核心技术
2010-12-31 01:16 2628http://www.berheley.com/jsnl/J2 ...
相关推荐
JavaMail邮件收发实例_JavaMail_API JavaMail邮件收发实例_JavaMail_API JavaMail邮件收发实例_JavaMail_API JavaMail邮件收发实例_JavaMail_API JavaMail邮件收发实例_JavaMail_API
基于JavaMail邮件系统的设计与实现,没有系统代码,只有论文
Javamail邮件开发 OA办公系统-邮件管理模块是一个小型的练习项目,运用java开发语言,MyEclipse 6.5开发工具,MySQL数据库。实现的功能是:对收件箱和发件箱中的邮件进行查询,删除,查看邮件详情和更改邮件已读未读...
javamail邮件
javamail邮件发送工具类 封装好的 可直接使用
javamail邮件开发包,用于邮件的收发和设计,用户在自己开发邮件客户端软件时需要用到
james_javamail邮件服务学习james_javamail邮件服务学习
javamail邮件收发机制
JavaMail邮件发送(带附件)
JavaMail邮件实战开发
javamail邮件开发.rar中包含apache-james-3.0-beta4-app服务器程序包和用于解决jdk7以上jar包冲突的jar包jaxb-impl-2.1.3.jar。开源工具commons-email-1.4.jar(这个其实也没什么用,因为使用maven添加依赖会自动...
javamail发送邮件;支持群发、单次发送;文本发送,html发送
javaMail邮件的收发,自带tomcat,下载后就可发布,演示运行、
javamail 邮件发送支持带有图片的html格式和普通文本格式
使用JAVAMail代发邮件 资源源于不但搜索,自由源于不但努力
很好的邮件处理代码,1.5版本,作为build path放在eclipse里面,就可以用啦! oracle官方推的,很好!jdk1.6版本以上用起来很方便。
javamail邮件发送程序 自己建工程测试时,会与javaEE中的包文件冲突。 可以先去年javaEE进行测试
JavaMail邮件发送程序所需JAR包,包含:commons-email-1.2.jar, activation.jar, mail.jar, commons-email-1.2-sources.jar, commons-email-1.2-javadoc.jar。
JBoss 实体Bean 及其接口的模版 (实现JavaMail邮件的接收)
JavaMail邮件发送-为你的邮件增加背景音乐和背景图片