• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >JSP > JSP发送邮件实例

JSP发送邮件实例

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-11

通过本文主要向大家介绍了jsp项目开发实例,jsp连接数据库实例,jsp调用servlet实例,jsp数据库编程实例,jsp网站开发实例等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
vishal_donth gave this response on 10/18/2000:  
//these are the pakages to be imported from  
// Java Mail  
//The Java Mail PAckage either be dowloaded  
//seperately  
//or else is Available in the J2sdkee1.2  
// (Java Enterprise Edition)  

import javax.mail.*;  
import javax.mail.internet.*;  
import java.util.*;  


//This function can be used to send the mail  
// with the parameters given to it  
//U have to specify the smtp server through  
//which u have to send the mail  
//since i was trying with a homenetmail  
//account i directly sent the mail its server  
//For sending this mail u need a mail server  
//which lets u to relay the messages  
//Try this thing for sending to a  
//www.homenetmail.com account because it lets  
//u send  
//mails to the accounts like example try  
//sending it to a "abc@homenetmail.com"  
//account.Create the mail account in homenet  
//mail first. If u get any other server which  
//supports relaying u can try this on that  
//also.  

//Use this function in ur Servlet to send  
//mail by calling the function with the  
//parameters  

public void sendMail(String toAddr, String subject, String body, String fromAddr)throws RemoteException{  
try{  
Properties props = new Properties();  
props.put("mail.smtp.host","mail.homenetmail.com");  
//Here we specify the SMTP server through  
//which the mail should be delivered  
Session session = Session.getDefaultInstance(props, null);  
Message msg = new MimeMessage(session);  
msg.setFrom(new InternetAddress(fromAddr));  
//Specify the From Address  
InternetAddress[] tos =InternetAddress.parse(toAddr);  
//Specify the To Address  
msg.setRecipients(Message.RecipientType.TO,tos);  
msg.setSubject(subject);  
//Specify the Subject  
msg.setText(body);  
//Specify the Body  
Transport.send(msg);  
System.out.println("Message is Sent");  
}  
catch(Exception e){  
System.out.println(e);  
}  
}  

// U have to run this function on a computer  
//which is directly connected  
// to internet but not through a  
//proxy......or else use a proxy which  
//supports SMTP  
</div>
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Jsp真分页实例---分页
  • jsp输出金字塔的简单实例
  • 使用JSP制作一个超简单的网页计算器的实例分享
  • 实例解析JSP中EL表达式的各种运用
  • jsp之c标签用法实例分析
  • JSP实现添加功能和分页显示实例分析
  • jsp分页显示完整实例
  • JSP上传文件到指定位置实例代码
  • jsp文件上传与下载实例代码
  • JSP分页显示的实例代码

相关文章

  • 2017-05-11解决中文乱码的几种解决方法(推荐)
  • 2017-05-11JSP使用ajaxFileUpload.js实现跨域问题
  • 2017-05-11解决jsp页面使用网络路径访问图片的乱码问题
  • 2017-05-11JSP 获取真实IP地址的代码
  • 2017-05-11无边框窗口代码详解
  • 2017-05-11JSP验证码动态生成方法
  • 2017-05-11jsp用过滤器解决中文乱码问题的方法
  • 2017-05-11为什么要学习Hibernate?
  • 2017-05-11JSP中九大内置对象和四种属性范围详解
  • 2017-05-11jsp hibernate的分页代码第1/3页

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 如何在Jsp中使用JDBC来联结MySql
    • jsp读取数据库实现分页技术简析
    • Spring MVC的文件下载实例详解
    • JSP学习之JavaBean用法分析
    • 在jsp程序中使用com组件
    • 写一个对搜索引擎友好的文章SEO分页类
    • jsp页面中EL表达式被当成字符串处理不显示值问题的解决方法
    • jsp实现页面实时显示当前系统时间的方法
    • JSP页面中超链接传递中文参数出现乱码问题解决方法
    • JSP程序使用JDBC连接MySQL的教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有