跪求一个企业邮局的服务器源码最好linux的!

跪求一个企业邮局的服务器源码最好linux的!,第1张

介绍下9种企业常用的Linux和Unix服务器

1.CentOS:

https://www.centos.org/

CentOS-5,CentOS-6,CentOS-7:http://wiki.centos.org/Download

2.Debian:

https://www.debian.org/

Debian 8.0:https://www.debian.org/releases/stable/debian-installer/

Old Debian Archive:https://www.debian.org/distrib/archive

Getting Debian from the Internet:

https://www.debian.org/distrib/ftplist

https://www.debian.org/distrib/

https://www.debian.org/CD/

3.Oracle Linux:

http://www.oracle.com/us/technologies/linux/overview/index.html

Oracle Linux Download:

http://www.oracle.com/us/technologies/linux/product/overview/index.html

https://edelivery.oracle.com/linux

http://www.oracle.com/technetwork/server-storage/linux/downloads/default-150441.html

4.Red Hat

https://www.redhat.com/en

Red Hat Download:https://access.redhat.com/downloads

https://www.redhat.com/en/technologies/linux-platforms/enterprise-Linux

5.suse linux enterprise server

https://www.suse.com/products/server/

https://www.suse.com/download-linux/

https://www.suse.com/zh-cn/download-linux/

6.Oracle Solaris

http://www.oracle.com/technetwork/server-storage/solaris11/downloads/index.html

http://www.oracle.com/technetwork/server-storage/solaris10/downloads/index.html

http://www.oracle.com/technetwork/systems/index.html

7.Ubuntu

http://www.ubuntu.com/download/server

http://www.ubuntu.com/download/desktop

http://www.ubuntu.com/download/alternative-downloads

8.IBM Aix

http://www-03.ibm.com/systems/power/software/aix/

9.HP-UX

http://en.wikipedia.org/wiki/HP-UX

http://www8.hp.com/us/en/products/servers/hp-ux.html#tab=TAB1

http://h18000.www1.hp.com/products/servers/byos/hpuxservers.html

 一.程序源码:

(1) 发送文本类型信件.这种是接收者收到后打开信箱后直接显示在邮件正文的.它主要有两个程序: mailform.html and sendmail.jsp,另外三个程序为提交成功和不成功及发生内部错误的处理程序.

mailform.html用来输入用户信息,然后提交表单给sendmail.jsp

sendmail.jsp 用来处理接收信息并处理信息,最后发送邮件.

<%--mailform.html 的源代码--%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>mailform.html</title>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

</head>

<body>

<form name="form1" method="post" action="sendmail.jsp">

<p align="center">填写邮件内容</p>

<div align="center">

<table width="75%" border="1">

<tr>

<td><div align="center">收件人</div></td>

<td><div align="center">

<input name="to" type="text" id="to" size="30" maxlength="30">

</div></td>

</tr>

<tr>

<td><div align="center">发件人</div></td>

<td><div align="center">

<input name="from" type="text" id="from" size="30" maxlength="30">

</div></td>

</tr>

<tr>

<td><div align="center">抄送</div></td>

<td><div align="center">

<input name="cc" type="text" id="cc" size="30" maxlength="100">

</div></td>

</tr>

<tr>

<td><div align="center">暗送</div></td>

<td><div align="center">

<input name="bcc" type="text" id="bcc" size="30" maxlength="100">

</div></td>

</tr>

<tr>

<td><div align="center">主题</div></td>

<td><div align="center">

<input name="subject" type="text" id="subject" size="30" maxlength="30">

</div></td>

</tr>

<tr>

<td colspan="2"><div align="center">

<textarea name="body" cols="40" rows="10" id="body"></textarea>

</div></td>

</tr>

<tr>

<td colspan="2"><div align="center">

<input type="submit" name="Submit" value="发送">

<input name="Reset" type="submit" id="Reset" value="清空">

</div></td>

</tr>

</table>

</div>

<p align="center"></p>

</form>

<p align="center"></p>

</body>

</html>

<%--sendmail.jsp 的源代码--%>

<%@page contentType="text/htmlcharset=gb2312"%>

<%@page errorPage="errpage.jsp"%>

<%@page import="java.util.*"%>

<%@page import="javax.mail.*"%>

<%@page import="javax.mail.internet.*"%>

<%@page import="javax.activation.*"%>

<html>

<head>

<title>sendmail.jsp</title>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

</head>

<body>

<%

//邮件服务器的IP地址,注意此时使用的是SMTP 邮件服务器

//String host="202.102.240.76"

//获取用户信息

String to=request.getParameter("to")

String from=request.getParameter("from")

String cc=request.getParameter("cc")

String bcc=request.getParameter("bcc")

//结合本程序的第一句,共同起显示汉字体的功能

String subject=request.getParameter("subject")

subject = new java.lang.String(subject.getBytes("iso-8859-1"))

//以上方法等同于以下两句,原理相同

//byte[] subjectTemp=request.getParameter("subject").getBytes("ISO8859_1")

//String subject=new String(subjectTemp)

byte[] messageTextTemp=request.getParameter("body").getBytes("ISO8859_1")

String messageText= new String(messageTextTemp)

boolean sessionDebug = false

//验证所填写的邮件是否正确

if((to.trim().indexOf("@")==-1)||(to.trim().length()<5)){

%>

<jsp:forward page="err.jsp"/>

<%

}

if((from.trim().indexOf("@")==-1)||(from.trim().length()<5)){

%>

<jsp:forward page="err.jsp"/>

<%

}

//获得系统属性对象,用下两句的任一句均可

//Properties props = System.getProperties()

Properties props=new Properties()

//设置SMTP主机

//以下一句是对任意的SMTP 邮件服务器均可,并且有了这一句,将不用设置传输协议了

props.put("mail.smtp.host", "smtp.jspinsider.com")

//这样将确定接收方的邮件服务器主机,

//props.put("mail.host",host)

//设置邮件传输协议方式

//props.put("mail.transport.protocol","smtp")

//获取邮件会话对象

Session mailSession = Session.getDefaultInstance(props,null)

mailSession.setDebug(sessionDebug)

try{

//创建MIME邮件对象

Message msg = new MimeMessage(mailSession)

//设置发信人

msg.setFrom(new InternetAddress(from))

//设置收信人

InternetAddress[] addressTo = {new InternetAddress(to)}

msg.setRecipients(Message.RecipientType.TO,addressTo)

//设置抄送人

if(cc.trim().length()!=0){

InternetAddress[] addressCc = {new InternetAddress(cc)}

msg.setRecipients(Message.RecipientType.CC,addressCc)

}

//设置暗送人

if(bcc.trim().length()!=0){

InternetAddress[] addressBcc = {new InternetAddress(bcc)}

msg.setRecipients(Message.RecipientType.BCC,addressBcc)

}

msg.setSubject(subject)

msg.setSentDate(new Date())

msg.setText(messageText)

//发送邮件

Transport.send(msg)

}

catch(Except

jsp如何实现发送电子邮件2007年11月07日 星期三 下午 11:35

关键字:|发送到邮件功能实现|网站建设|功能组件|在线发邮件|文章发送到邮件|

一、准备工作很麻烦 整理:http://hi.baidu.com/start%5Flife

1、下载javamail的包

java.sun.com/products/javamail/downloads/index.html

将 mail.jar 复制到 lib 目录中

2、下载activation 包

java.sun.com/products/javabeans/jaf/downloads/index.html

将activation.jar复制到 lib 目录中

3、再把服务器重启下

二、下面是一个简单的发送文本内容的例子,直接在jsp中进行操作。可以自己设置smtp的地址,用户名和密码,这是javamail最简单的应用,它的功能超强,可以发附件,可以收邮件等。

<%@page contentType="text/htmlcharset=gb2312"%>

<%@ page import="javax.mail.*,javax.activation.*,javax.mail.internet.*,java.util.*"%>

<html>

<head>

<title>JavaMail 电子邮件发送</title>

</head>

<body>

<%!

public class MailAuthenticator extends Authenticator{

String authenName

String authenPass

public MailAuthenticator(String authenName,String authenPass) {

super()

this.authenName=authenName

this.authenPass=authenPass

}

public PasswordAuthentication getPasswordAuthentication(){

return new PasswordAuthentication(authenName,authenPass)

}

}

%>

<%

MailAuthenticator ma = new MailAuthenticator("","")

//这里第一个参数是用户名,第二个是密码。 如果是匿名服务器,可以设置为空

Properties props = new Properties()

Session sendMailSession

Transport transport

sendMailSession = Session.getInstance(props,ma)

Message newMessage = new MimeMessage(sendMailSession)

newMessage.setFrom(new InternetAddress("test@test.com"))//发件人

newMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("wxg_bj@yahoo.com.cn"))//目标邮箱

newMessage.setSubject("subject")//这个是标题

newMessage.setSentDate(new Date())

newMessage.setText("text")//文本内容

props.put("mail.smtp.host","192.168.0.1")//这里设置smtp服务器地址 ,我设置的是本机

props.put("mail.smtp.auth","true")//这里true代表需要密码验证,如果是匿名服务器,可以设置为false,当然,设置为ture也无所谓,只要名和密码设置为空

transport = sendMailSession.getTransport("smtp")

try{

transport.send(newMessage)

//发送

}catch(Exception e){

System.out.println(e)

}

%>

</BODY>

</HTML>

项目导入mail.jar了吗?

protected PasswordAuthentication getPasswordAuthentication()

{

//这里的USER_NAME和USER_PWD分别写你的邮箱名和密码,不写密码怎么发送呢?

return new PasswordAuthentication(USER_NAME,USER_PWD)

//我看你是做了张jsp网页,然后通过request.getParameter获取页面值,那这也要接受的

}

这句话好象没写.

prop.put("mail.smtp.host",HOST_NAME)

最后补充一点.有时候代码完全正确,也会不能发送.因为你的邮箱没得到验证,近几年申请的普通邮箱都是没通过验证的.所以你是那种邮箱的话就没办法了.


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/68623.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-01
下一篇2023-03-01

发表评论

登录后才能评论

评论列表(0条)

    保存