java郵件系統(tǒng)代碼 java開源郵件系統(tǒng)

100高分誠求:Java郵件系統(tǒng)源代碼

你的這個要求有點離譜,如果真的要的話

10年積累的成都網(wǎng)站設(shè)計、成都網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有長春免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

建議去這個找吧,源代碼都有的

求一個javaweb郵件收發(fā)系統(tǒng)eclipse源代碼,tomcat可以運行的。

package me.gacl.main;

import java.util.Properties;

import javax.mail.Message;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeMessage;

public class Sendmail {

/**

* @param args

* @throws Exception

*/

public static void main(String[] args) throws Exception {

Properties prop = new Properties();

prop.setProperty("mail.host", "smtp.sohu.com");

prop.setProperty("mail.transport.protocol", "smtp");

prop.setProperty("mail.smtp.auth", "true");

//使用JavaMail發(fā)送郵件的5個步驟

//1、創(chuàng)建session

Session session = Session.getInstance(prop);

//開啟Session的debug模式,這樣就可以查看到程序發(fā)送Email的運行狀態(tài)

session.setDebug(true);

//2、通過session得到transport對象

Transport ts = session.getTransport();

//3、使用郵箱的用戶名和密碼連上郵件服務(wù)器,發(fā)送郵件時,發(fā)件人需要提交郵箱的用戶名和密碼給smtp服務(wù)器,用戶名和密碼都通過驗證之后才能夠正常發(fā)送郵件給收件人。

ts.connect("smtp.sohu.com", "gacl", "郵箱密碼");

//4、創(chuàng)建郵件

Message message = createSimpleMail(session);

//5、發(fā)送郵件

ts.sendMessage(message, message.getAllRecipients());

ts.close();

}

/**

* @Method: createSimpleMail

* @Description: 創(chuàng)建一封只包含文本的郵件

* @param session

* @return

* @throws Exception

*/

public static MimeMessage createSimpleMail(Session session)

throws Exception {

//創(chuàng)建郵件對象

MimeMessage message = new MimeMessage(session);

//指明郵件的發(fā)件人

message.setFrom(new InternetAddress("gacl@sohu.com"));

//指明郵件的收件人,現(xiàn)在發(fā)件人和收件人是一樣的,那就是自己給自己發(fā)

message.setRecipient(Message.RecipientType.TO, new InternetAddress("gacl@sohu.com"));

//郵件的標題

message.setSubject("只包含文本的簡單郵件");

//郵件的文本內(nèi)容

message.setContent("你好??!", "text/html;charset=UTF-8");

//返回創(chuàng)建好的郵件對象

return message;

}

}

java發(fā)送郵件時出現(xiàn)的錯誤,端口什么的都開了

今天在做內(nèi)網(wǎng)郵箱發(fā)送功能時報如下錯誤:

554 Relay rejected for policy reasons.

測試時給內(nèi)容郵箱發(fā)送正常,給126發(fā)送就報如上錯誤,后來查看是權(quán)限限制的問題。

在網(wǎng)上查找到郵件發(fā)送時的常見問題總結(jié),備注一下。

介紹郵件系統(tǒng)常見的錯誤代碼及解釋,還有客戶端報錯相關(guān)信息

按照下列“Q”代表問題,“A”代表解答。

Q:the server says:550 relaying mail to is not allowed

Q:The server says:550 ... relaying denied

Q:the server says:550 5.7.1 relaying not permitted:

A:使用某些Smtp服務(wù)器時,限制了收件人的地址,只能換一個Smtp服務(wù)器。

Q:The server says:550 :local user only

Q:The server says:550 :Invalid User

Q:The server says:550 Invalid recipient

A:使用163.NET,163.com,yeah.Net和netease.com之類的Smtp服務(wù)器時,只能用自身的信箱發(fā)信,所以要在Outlook Express的“帳戶屬性”中的“個人信息”里面填寫正確的郵件地址。

Q:the server says:551 delivery not allowed to non-local recipient

Q:The server says:553 Relay restriction.

Q:The server says:553 From , message blocked.

Q:The server says:553 sorry,you are not allow to use this SMTP to relay your eami

Q:The server says:553 sorry, that domain isn't in my list of allowed rcpthosts

A:使用21cn.com,china.com,371.net,sina.com等大多數(shù)信箱的smtp服務(wù)器時,只能用自身的信箱發(fā)信,所以要在Outlook Express的“帳戶屬性”中的“個人信息”里面填寫正確的郵件地址。

Q:The server says:505 client was not authenticated

Q:The server says:553 authentication is required to send mail as

A:使用263.net和sohu.com的Smtp服務(wù)器時,不但要用自身的郵箱發(fā)信,而且要加入身份驗證,所以即要在“個人信息”中填寫正確郵箱地址,又要選中“SMTP服務(wù)器需要認證”。

Q:The server says:535 Error:authenticatin failed

Q:The server says:535 Authentication unsuccessful

Q:The server says:452 Insufficient system storage

A:在使用Esmtp認證的過程中出錯,檢查一下Esmtp設(shè)置,多試幾次。

Q:The server says:553 ...domain name required

Q:The server says:550 Unable to relay for ...

A:多出現(xiàn)在用Wingate代理服務(wù)器發(fā)送郵件時。雖然在Wingate中“POP3 郵箱帳號”要使用“用戶名#POP3地址”的格式,但在“帳戶屬性”中的“個人信息”中還是要填寫一般的格式。

Q:The server says:553 mailbox name not allowed

A:收件人郵箱地址不允許,需檢查收件人地址是否正確。

Q:the server says:553 sorry, your envelop sender is in my badmailfrom list

A:服務(wù)器限制了收件人的地址,只能換一個smtp服務(wù)器發(fā)信。

Q:the server says:554 Transaction failed

Q:The server says:451 Requested action aborted,errno=28

A:傳輸失敗,檢查網(wǎng)絡(luò)問題。

Q:the server says:503 error:needmail command

Q:The server says:503 need mail before RCPT.

Q:The server says:503 Bad sequence of commands

A:消息命令順序出錯,一般出現(xiàn)在其他錯誤之后,先檢查之前出現(xiàn)的錯誤提示。

Q:The Server says:501 syntax.helo hostname

Q:The server says:501 Invalid domain name

Q:The server says:502 unimplemented command

Q:the server says:503 5.0.0 polite people say HELO first

Q:The server says:533 relay restriction

Q:The server says:544 :Recipient address rejected: Relay access denied

A:傳輸中的語法錯誤,原因不明。

連接服務(wù)器錯誤,請檢查您的網(wǎng)絡(luò)設(shè)置。如果安裝防火墻/殺毒軟件,請檢查防火墻/殺毒軟件是否允許DreamMail程序訪問 Internet。

賬號“xxx”發(fā)送郵件錯誤,錯誤代碼:554;錯誤信息:554 Relay rejected for policy reasons.(檢查郵件系統(tǒng)是否有發(fā)送外網(wǎng)郵箱的權(quán)限)

附相關(guān)資料

SMTP 有一組固定的響應(yīng)代碼,表示郵件服務(wù)器對于傳送郵件要求的響應(yīng)狀況。其中 421、450、451、452、550、551、552、553、554 等 9 組代碼表示您要求郵件服務(wù)器執(zhí)行的動作不成功。

354

Start Mail input

開始傳輸郵件正文

421

domain Service not available, closing transmission channel

括號內(nèi)的主機無法提供正常服務(wù),關(guān)閉傳送管道,郵件將滯留在主機上

440

郵件址錯誤

445

Server Rejected

被封鎖

450

Client host rejected, Cannot resolve PTR

Temporary Process Error

Resource temporarily unaviable,please try again later

Requested mail action not taken: mailbox unavailable

無法 IP 反查

Requested mail action not taken: mailbox unavailable

所要求的郵件動作無法執(zhí)行:郵件信箱無法提供服務(wù),郵件將滯留在主機上

451

Domain of sender address sender@mail.com.tw does not resolve

qq trouble creating files in queue (#4.3.0)

queuename: Cannot create "qfCAA21081" in "/var/spool/mqueue" (euid=0): No space left on device

Requested action aborted, errno=28.

無法解析寄件者郵件地址

Requested action aborted: local error in processing

要求動作中斷:本地端錯誤

Requested action aborted,errno=28

傳送失敗,檢查網(wǎng)絡(luò)問題。

452

Message for would exceed mailbox quota

Requested action not taken: insufficient system storage

要求動作無法執(zhí)行:系統(tǒng)空間不足

Insufficient system storage

在使用Esmtp認證的過程中出錯,檢查一下Esmtp設(shè)置,多試幾次。

454

Client was not authenticated

安全因素,被封鎖

472

sender@mail.com.tw no DNS A-data returned

無法 IP 反查

501

Domain of sender address sender@mail.com.tw does not exist

無法 IP 反查

Mailbox not found

5.1.1 ... User unknown

無此使用者

Syntax error,parameters in command "RCPT TO:min@laohuyatse.com.tw"unrecognized or missing

no local part

Syntax error in recipient:

"@" or "." expected after "CC"

"@" or "." expected after "fau" :

email格式l錯誤

503

Either sender or receiver must be local account.

安全因素,權(quán)限不足

CAT@MAIL.FORTEK.COM.TW

無此使用者,不是本主機轉(zhuǎn)送信件的使用者

error:needmail command

need mail before RCPT

Bad sequence of commands

消息命令順序出錯,一般出現(xiàn)在其他錯誤之后,先檢查之前出現(xiàn)的錯誤提示。

5.0.0 polite people say HELO first

傳輸中的語法錯誤,原因不明

505

client was not authenticated

使用263.net和sohu.com的Smtp服務(wù)器時,不但要用自身的郵箱發(fā)信,而且要加入身份驗證,所以即要在"個人信息"中填寫正確郵箱地址,又要選中"SMTP服務(wù)器需要認證"。

521

This system is configured to reject mail from 211.20.70.148

安全因素,被封鎖

535

Error:authenticatin failed

Authentication unsuccessful

在使用Esmtp認證的過程中出錯,檢查一下Esmtp設(shè)置,多試幾次。

550

unknown user

User unknown

Invalid User

Recipient unknown

Mailbox disabled for this recipient

Unknown local part

Invalid recipient

Unable to relay for no such user

Recipient unknown

This account is not allowed

recipient unknown

No such mail drop defined,user disabled

I don't know

Relaying is prohibited

Relaying denied

relaying mail to is not allowed

... relaying denied

5.7.1 relaying not permitted:

REJECT SMTP Protocol Returned a Permanent Error 550 Forwarding percent hack is not permitted

Requested action not taken: mailbox unavailable

無此使用者,所要求動作無法執(zhí)行:信箱不存在,郵件將退回給寄件者,或者限制了收件人的地址,只能換一個Smtp服務(wù)器。

System is busy

郵件系統(tǒng)錯誤

Subj similar too many!!

太多同主題信件

Relaying denied. IP name lookup failed

IP name lookup failed

DNS FAILURE

cannot route to sender address

無法 IP 反查

Relaying denied

Mailbox unavailable: This site may not be used as a relay agent.

無法轉(zhuǎn)寄

:local user only

:Invalid User

Invalid recipient

使用163.net,163.com,yeah.net和netease.com之類的Smtp服務(wù)器時,只能用自身的信箱發(fā)信,所以要在Outlook Express的"帳戶屬性"中的"個人信息"里面填寫正確的郵件地址。

Unable to relay for ...

多出現(xiàn)在用Wingate代理服務(wù)器發(fā)送郵件時。雖然在Wingate中"POP3 郵箱帳號"要使用"用戶名#POP3地址"的格式,但在"帳戶屬性"中的"個人信息"中還是要填寫一般的格式。

551

we do not relay ...

delivery not allowed to non-local recipient

無法轉(zhuǎn)寄,使用21cn.com,china.com,371.net,sina.com等大多數(shù)信箱的smtp服務(wù)器時,只能用自身的信箱發(fā)信,所以要在Outlook Express的"帳戶屬性"中的"個人信息"里面填寫正確的郵件地址。

User not local; please try forward-path

郵件服務(wù)器知道使用者不屬于本地端,將嘗試括號內(nèi)的轉(zhuǎn)送路徑

552

Requested mail action aborted: exceeded storage allocation

所要求的動作中斷:超出所分配的儲存空間,郵件將退回給寄件者

Sorry, we don't allow mail from your host.

被封鎖

553

sorry, that domain isn't in my list of allowed rcpthosts

mailbox name not allowed

郵件地址錯誤

Requested action not taken: mailbox name not allowed

sorry, your envelop sender is in my badmailfrom list

所要求的動作未執(zhí)行:信箱不允許該動作執(zhí)行 ,或者服務(wù)器限制了收件人的地址,只能換一個smtp服務(wù)器發(fā)信。

Relay restriction.

From , message blocked.

sorry,you are not allow to use this SMTP to relay your eami

sorry, that domain isn't in my list of allowed rcpthosts

使用21cn.com,china.com,371.net,sina.com等大多數(shù)信箱的smtp服務(wù)器時,只能用自身的信箱發(fā)信,所以要在Outlook Express的"帳戶屬性"中的"個人信息"里面填寫正確的郵件地址。

authentication is required to send mail as

使用263.net和sohu.com的Smtp服務(wù)器時,不但要用自身的郵箱發(fā)信,而且要加入身份驗證,所以即要在"個人信息"中填寫正確郵箱地址,又要選中"SMTP服務(wù)器需要認證"。

...domain name required

多出現(xiàn)在用Wingate代理服務(wù)器發(fā)送郵件時。雖然在Wingate中"POP3 郵箱帳號"要使用"用戶名#POP3地址"的格式,但在"帳戶屬性"中的"個人信息"中還是要填寫一般的格式。

554

delivery error: dd This user doesn't have a yahoo.com account

delivery error: dd Sorry, your message to xxxxyahoo.com cannot be delivered. This account is over quota.

無此使用者

Transaction failed

傳送失敗,檢查網(wǎng)絡(luò)問題。

571

we don't accept junk mail (mail.sysnet.net.tw)

無效的寄件者

java mail發(fā)送郵件問題

給你貼段代碼 含注釋的 要不不明白在問吧~~:-)

package com.company.paging.service.Impl;

import java.io.File;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Properties;

import java.util.UUID;

import javax.activation.DataHandler;

import javax.activation.FileDataSource;

import javax.mail.Authenticator;

import javax.mail.PasswordAuthentication;

import javax.mail.Session;

import javax.mail.Transport;

import javax.mail.Message.RecipientType;

import javax.mail.internet.InternetAddress;

import javax.mail.internet.MimeBodyPart;

import javax.mail.internet.MimeMessage;

import javax.mail.internet.MimeMultipart;

import javax.mail.internet.MimeUtility;

import com.company.paging.service.MailService;

/**

* @ProjectName:paging

* @ClassName:MailServiceImpl

* @Description:TODO mail業(yè)務(wù)邏輯接口實現(xiàn)類

* @author:Administrator

* @date:2011-1-20 上午10:20:39

* @version v1.0

*

*/

public class MailServiceImpl implements MailService {

//協(xié)議

String protocol="smtp";

//發(fā)送郵箱

String from="發(fā)送郵件地址";

//String subject="HTML測試";

//smtp服務(wù)器

String server="smtp.sina.com";

//用戶名

String user="";

//密碼

String pass="";

public void sendMail(String address, String subject, String content,

File[] files) throws Exception {

// TODO Auto-generated method stub

Session session=createSession();

MimeMessage message=createMessage(session,address,subject,content,files);

System.out.println(message.getMessageID()+"=================");

Transport.send(message);

}

public void sendMail(String address, String subject, String content)

throws Exception {

// TODO Auto-generated method stub

sendMail(address, subject, content,null);

}

public void sendActivateLink(String address) throws Exception {

// TODO Auto-generated method stub

String subject = "帳戶激活郵件。";

String nowTime = new SimpleDateFormat("yyyymmddHHmmss").format(new Date());// 當前時間

//生成激活碼

String code=nowTime+ UUID.randomUUID().toString();

//生成內(nèi)容

StringBuilder content = new StringBuilder();

content.append(",你好:");

content.append("? ? strong請在激活帳號以后,使用用戶名密碼登錄。此郵件系統(tǒng)自動發(fā)送,請勿回復(fù)。/strong");

sendMail(address, subject, content.toString());

}

/**

* @Title: createSession

* @Description: TODO 創(chuàng)建mail session

* @return Session

*/

private Session createSession(){

//創(chuàng)建屬性文件

Properties props=new Properties();

//設(shè)置協(xié)議

props.setProperty("mail.transport.protocol", protocol);

//設(shè)置是否認證

props.setProperty("mail.smtp.auth","true");

//設(shè)置smtp服務(wù)器地址

props.setProperty("mail.host", server);

//創(chuàng)建session

Session session = Session.getInstance(props,

new Authenticator(){

protected PasswordAuthentication getPasswordAuthentication(){

return new PasswordAuthentication(user,pass);

}

}

);

//是否打印mail字符串

session.setDebug(true);

return session;

}

/**

* @Title: createMessage

* @Description: TODO 創(chuàng)建郵件體

* @param session 郵件發(fā)送session

* @param address 郵件地址字符串 "\"張三\"zhangsan@163.com,"

* @param subject 郵件主題

* @param content 郵件內(nèi)容(html)

* @param files 附件數(shù)組

* @throws Exception

* @return MimeMessage

*/

private MimeMessage createMessage(Session session, String address, String subject, String content, File[] files)throws Exception{

//創(chuàng)建郵件

MimeMessage message=new MimeMessage(session);

//設(shè)置發(fā)件人

message.setFrom(new InternetAddress(from));

//設(shè)置收件人

message.setRecipients(RecipientType.TO,

InternetAddress.parse(address)

);

//設(shè)置郵件主題

message.setSubject(subject);

//創(chuàng)建用于組合郵件正文和附件的MimeMultipart對象

MimeMultipart allMultipart=new MimeMultipart("mixed");

//創(chuàng)建代表郵件正文和附件的各個MimeBodyPart對象

MimeBodyPart contentPart=createContent(content);

allMultipart.addBodyPart(contentPart);

//創(chuàng)建附件

if(files!=null){

for(File file:files){

if(file.isFile()){

MimeBodyPart attchPart=createAttachment(file);

allMultipart.addBodyPart(attchPart);

}

}

}

//設(shè)置整個郵件內(nèi)容為最終組合的MimeMultipart對象

message.setContent(allMultipart);

message.saveChanges();

return message;

}

/**

* @Title: createContent

* @Description: TODO 創(chuàng)建內(nèi)容體

* @param body

* @throws Exception

* @return MimeBodyPart

*/

private MimeBodyPart createContent(String body)throws Exception{

//創(chuàng)建代表組合MIME消息的MimeMultipart對象,和將該MimeMultipart對象保存到MimeBodyPart對象

MimeBodyPart contentPart=new MimeBodyPart();

MimeMultipart contentMultipart=new MimeMultipart("related");

//創(chuàng)建用于保存HTML正文的MimeBodyPart對象,并將它保存到MimeMultipart中

MimeBodyPart htmlBodyPart=new MimeBodyPart();

htmlBodyPart.setContent(body,"text/html;charset=gb2312");

contentMultipart.addBodyPart(htmlBodyPart);

//將MimeMultipart對象保存到MimeBodyPart對象中

contentPart.setContent(contentMultipart);

return contentPart;

}

/**

* @Title: createAttachment

* @Description: TODO 創(chuàng)建附件體

* @param file

* @throws Exception

* @return MimeBodyPart

*/

private MimeBodyPart createAttachment(File file)throws Exception{

//創(chuàng)建保存附件的MimeBodyPart對象,并加入附件內(nèi)容和相應(yīng)信息

MimeBodyPart attachPart=new MimeBodyPart();

FileDataSource fds=new FileDataSource(file);

attachPart.setDataHandler(new DataHandler(fds));

attachPart.setFileName(MimeUtility.encodeText(fds.getName()));

return attachPart;

}

}

Java發(fā)送郵件

JAVA郵件發(fā)送的大致過程是這樣的的:

1、構(gòu)建一個繼承自javax.mail.Authenticator的具體類,并重寫里面的getPasswordAuthentication()方法。此類是用作登錄校驗的,以確保你對該郵箱有發(fā)送郵件的權(quán)利。

2、構(gòu)建一個properties文件,該文件中存放SMTP服務(wù)器地址等參數(shù)。

3、通過構(gòu)建的properties文件和javax.mail.Authenticator具體類來創(chuàng)建一個javax.mail.Session。Session的創(chuàng)建,就相當于登錄郵箱一樣。剩下的自然就是新建郵件。

4、構(gòu)建郵件內(nèi)容,一般是javax.mail.internet.MimeMessage對象,并指定發(fā)送人,收信人,主題,內(nèi)容等等。

5、使用javax.mail.Transport工具類發(fā)送郵件。

請教JAVA 郵件系統(tǒng)的設(shè)計,以及一些業(yè)務(wù)邏輯.

個人想法,請參考:

1.保存到文件夾吧,我覺得不用移除附件。 遇到有過濾附件的需求時再考慮吧。

2.存郵件表的應(yīng)該是包含郵件列表頁面顯示的內(nèi)容吧。內(nèi)容之外的是不是就可以不在這張表里存了。比如抄送地址這種,就一并存到文件里吧,算是郵件頭。查看的時候解析。

3.同意,exchange web就是這樣的。

4.統(tǒng)一用utf8編碼吧

5.這個不太清楚,不好意思。

6.中間有異常的話是不是要算成草稿。就是1(入庫+寫文件)2 發(fā)送 3 根據(jù)發(fā)送修改數(shù)據(jù)記錄

7.不太清楚具體情況。debug一下呢? 內(nèi)存中沒有大數(shù)據(jù)的處理吧?

當前名稱:java郵件系統(tǒng)代碼 java開源郵件系統(tǒng)
文章起源:http://muchs.cn/article4/hgijoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、靜態(tài)網(wǎng)站、ChatGPT、服務(wù)器托管微信公眾號、響應(yīng)式網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)