把JavaMail包装成简单的Sendmail

Java Sendmail Jar包 Java Call Sendmail Jar包 SMTP 立即下载
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

package steeven;



/*

Calss:  Sendmail

Author: steeven@kali.com.cn

QQ:     7461522

Date:   11/13/2001

Notes:

        Find samples in main();

        If you send mail only from/to intranet, change domain as u need.

Setup:

        1. change host, mailFooter

*/





import java.util.*;

import java.sql.*;

import javax.mail.*;

import javax.mail.internet.*;

import javax.activation.*;



public class Sendmail extends Common{



  public String host = "smtpServer";              //smtp server

  static String mailFooter = "/n/n/n此邮件由WebMail发送 http://www/mail.jsp/n/n";

  String domain = "company";

  boolean sessionDebug;



  Message msg;

  Multipart multipart;



  public Sendmail() throws Exception{

    Properties props = System.getProperties();

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

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

    Session session = Session.getDefaultInstance(props, null);

    // Set debug on the Session so we can see what is going on

    // Passing false will not echo debug info, and passing true

    // will.

    session.setDebug(sessionDebug);

    // Instantiate a new MimeMessage and fill it with the

    // required information.

    msg = new MimeMessage(session);

    msg.setSentDate(new java.util.Date());

    multipart = new MimeMultipart();

    msg.setContent(multipart);

  }

  public Sendmail(String to, String from, String subject, String body) throws Exception{

    this();

    this.setSendTo(to);

    this.setFrom(from);

    this.setSubject(subject);

    this.setBody(body);

  }

  public Sendmail(String[] to, String from, String subject, String body) throws Exception{

    this();

    this.setSendTo(to);

    this.setFrom(from);

    this.setSubject(subject);

    this.setBody(body);

  }

  public void setHost(String host) throws Exception{

    this.host=host;

  }

  void setFrom(String from) throws Exception{

    msg.setFrom(new InternetAddress(from "@" domain));

  }

  void setSendTo(String[] to) throws Exception{

    for (int i=0;i
ERA5获取的风场数据转换为.dfs2文件 ERA5获取风场数据的具体步骤可以参考下面的文章下载好后应该是.nc格式的文件,想要读取或者转换成其他格式的文件可以安装下面步骤,本文介绍如何转换为.dfs2文件。 阅读详情

相关推荐

vue3的面试题

vue3的面试题

jiang7701037的博客 6275

java实现发送邮件

本文介绍下java实现邮件的发送,意在网站用户评论时能够及时通知站长和用户评论被回复后能够及时通知用户。下文介绍下具体实现。

weixin_46630782的博客 3647

Mac上Ollama服务IP访问失败的3种修复方法(含永久生效配置)

本文详细介绍了Mac上Ollama服务IP访问失败的3种修复方法,包括临时环境变量覆盖、永久Shell配置修改及进阶排查技巧。重点解析了OLLAMA_HOST环境变量的配置原理,帮助开发者解决Connection refused问题,实现局域网IP访问Ollama服务的需求。

weixin_29209805的博客 213

Java实现发送邮件功能

邮件参数配置/***/// 发件人// 发件主机// 发件人账号// 发件人密码发送邮件/***/// 发送邮件// 定义收件人try {// 获取系统属性// 设置邮件服务器// 获取默认session对象@Override});// 定义头部字段及发邮件try {// 创建默认的MimeMessage对象// 设置发件人From 头部字段// 设置收件人To 头部字段// 设置Subject 头部字段。

2401_85117728的博客 873

Anaconda/Miniconda的删除和安装

要在 MacBook 上删除 Anaconda 或 Miniconda,并重新安装它,您可以按照以下步骤进行操作。

qq_27390023的博客 3034

LSTM模型股价波动率预测(含Python代码)

源代码文件可在gzh’finance褪黑素'回复【24012203】获取。

celiaweiwei的博客 3779

java sendemail_Java发送Email/邮件(转载)

使用Java应用程序发送邮件是很简单的,需要安装JavaMail API和Java Activation Framework (JAF)在机器上。可以从Java的标准网站上下载JavaMail(版本1.2)的最新版本。可以从Java的标准网站下载最新版本的JAF(版本1.1.1)。下载并解压缩这些文件,在新创建的顶层目录,会发现一些jar文件应用。需要添加了mail.jar和activatio...

weixin_32233571的博客 486

国资e学快速学习实战教程

本文主要介绍了国资e学快速学习实战教程,希望能对同学们有所帮助。 文章目录 1. 前言 2. 实战教程

weixin_43178406的博客 11万+

如何使用Java Mail发邮件(包括单发和群发),含演示代码下载

JavaMail,顾名思义,提供给开发者处理电子邮件相关的编程接口。它是Sun发布的用来处理email的API。它可以方便地执行一些常用的邮件传输。我们可以基于JavaMail开发出类似于Microsoft Outlook的应用程序。使用JavaMail可以很方便的在Java客户端实现 发邮件的功能。

madifu的博客 5870

Cesium+Vue3教程(003):基于Vue3的Cesium自定义地图和地图叠加

在 Cesium 中,是用于加载地表影像图层的核心接口。通过它,您可以将各种地图服务(如卫星影像、街道地图、自定义瓦片等)加载到 Cesium 的地球上。Cesium 提供了多个内置的。

WwLK123的博客 640

8-bit量化在YOLOv11中的部署实践-(使用PTQ、QAT量化技术实现模型体积压缩和推理加速)

本文系统介绍了YOLOv11模型量化技术,主要包括三个核心部分:首先阐述模型量化的基础理论,包括量化分类、数学原理和性能影响;其次分析YOLOv11架构特点及其量化敏感层;最后详细讲解训练后量化(PTQ)的具体实现流程。研究表明,8-bit量化可使YOLOv11模型大小缩减至1/4,推理速度提升1.7-2.3倍,精度损失控制在1%以内。文章特别强调了校准算法选择(如最小最大值法和KL散度法)对量化效果的关键影响,并提供了完整的代码实现示例,为YOLOv11的高效部署提供实用指导。

本博客聚焦 YOLOv11 全流程落地,涵盖架构优化、数据集处理、训练技巧与多场景部署,兼及国产数据库、Java 开发与 AI 模型应用,内容兼顾理论与工程实践,为开发者提供系统干货,助力高效提升技术能力。 1631

Java实现邮件发送

Java实现邮件发送 一、邮件服务器与传输协议 要在网络上实现邮件功能,必须要有专门的邮件服务器。这些邮件服务器类似于现实生活中的邮局,它主要负责接收用户投递过来的邮件,并把邮件投递到邮件接收者的电子邮箱中。 SMTP服务器地址:一般是 smtp.xxx.com,比如163邮箱是smtp.163.com,qq邮箱是smtp.qq.com。 SMTP协议 通常把处理用户smtp请求(邮件...

baolingye的博客 14万+

VS2019编译配置Easy3D

VS2019编译配置Easy3D

dayuhaitang1的博客 2604

把JavaMail包装成简单的Sendmail (转)

把JavaMail包装成简单的Sendmail (转)[@more@]package steeven;/*Calss:SendMailAuthor: steeven@kali.com.cnqq: 7461522Date:1...

csd3176的博客 198

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

javamail发送邮件--sendmail

package com.mail;import org.apache.log4j.Logger;import java.util.* ;import java.io.*;import org.apache.log4j.Logger;import javax.mail.* ;import javax.mail.internet.* ;import javax.activation.* ;

ziying的专栏 2621

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

javamail 利用 sendmail 发送邮件

今天需求是系统利用自己的smtp服务器发送邮件,我们的系统架构建立在appfuse基础上的,实际上是利用spring mail对javamail的封装调用,以前一直用的是第三方的smtp服务。 开始考虑postfix,口碑好,搞了半天,架设好了,需要域名mx记录支持,我们仅仅是测试使用,没有域名用例测试,没有搞好!但我们的机器上的sendmail可以向外发送邮件的。 于是把原来

cb_121的专栏 3966

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

用JSP发送EMAIL(JavaMail简易实现版)

 在这里可以下载JAVAMAIL包 http://java.sun.com/products/javamail/在解压后,将activation.jar和mail.jar复制到 /WEB-INF/lib 目录后,JAVAMAIL便可以正常使用了下面sendmail.jsp 内容如下%@page contentType="text/html;charset=gb2312"%>JavaMa

SkyPirate的专栏 5395

项目中用到的2个工具类代码:FTP与SendMail

今天刚写了几个代码,用在正在开发的项目中虽然是从各处找来的,但是经过我修改完善了一下1 SendMail -- 用于项目中贺卡的发送  原本来自于 aistill原作的代码:http://www.csdn.net/Develop/Read_Article.asp?Id=14929   本代码修改了一些实现。可增加任意附件,可支持HTML  可以不考虑设定标题、内容的是否合理等  本类采用了Ja

冰云BLOG 5212

jsp+servlet实现javamail(3)

最后就是写可以实现邮件发送功能的JAVAMAIL函数了。注意把这个类放在和刚刚sevlet类的同一个包下面。 package com.test;import javax.mail.*;import javax.mail.internet.*;import java.util.*;import java.util.Properties;import javax.activat

菜鸟MM学编程 1207

sendmail-命令行发邮件利器

前段时间公司的一个项目刚刚上线,为了每天都能够查看系统中昨天出现的问题等各种关键信息,开发人员每天都远程登陆系统拿到产生的系统日志等其他文件,由于远程登陆还需要VPN,使用起来相当繁琐,并且效率不高,为此花掉的时间也挺多的.想了一想如何解决这个问题,得出的结论这种重复无意义的事情还是交给计算机做比较合适,于是花了周末的一个下午的时间使用Java编写了支持在命令行发送邮件的jar包,然后通过bat脚

奇点临近 2万+

sendMail

//package com.sksoft.xml.javamail;//package sk;import java.util.*;import javax.mail.*;import javax.mail.internet.*;import java.util.Date;import javax.activation.*;import java.io.*;public class sendMai

程驰天下的专栏 847

Email发送器 JavaMail实例

用JavaMail完成一个Email 发送器小组件只需要两个类: 1.Constant.java  储存基本上不需要改变的参数 public class Constant { public static final String mailAddress ="发送方邮箱地址"; public static final String mailCount ="发送方邮箱密码"; publ

ruiruibaobei1993的博客 937

Java发送邮件(利用Javamail包,最简单的发送邮件demo)

今天网站要用到发送邮件功能,于是乎就研究了下如何利用java发送邮件。其实网站发送邮件的功能特别重要,比如激活的时候,很多网站激活都需要通过邮件激活的。对于java来说可以通过javamail这个包来实现。下面给出一个demo。有兴趣的可以直接拿去用。 package com.levi.servlet; import java.util.Properties; import javax.ma

花2不谢 5283
上一篇: 用JAVA实现线程等待提示框
下一篇: Apusic Application Server1.0中jsp源代码泄漏漏洞
java169
博客等级 码龄19年 27粉丝 2568原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址