主頁 > 知識庫 > 郵件發(fā)送簡單例子-bean文件

郵件發(fā)送簡單例子-bean文件

熱門標(biāo)簽:廣州三五防封電銷卡 珠海銷售外呼系統(tǒng)運(yùn)營商 四川電信外呼系統(tǒng)靠譜嗎 外呼系統(tǒng)啥意思 電銷外呼系統(tǒng) 排行榜 長春回?fù)芡夂粝到y(tǒng)廠家 地圖標(biāo)注制作道路 山東智能云外呼管理系統(tǒng) 地圖標(biāo)注創(chuàng)業(yè)項(xiàng)目入駐
SimpleSendMessage.java

import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SimpleSendMessage {

public static void main(String[] args) {

// Collect the necessary information to send a simple message
// Make sure to replace the values for host, to, and from with
// valid information.
// host - must be a valid smtp server that you currently have
// access to.
// to - whoever is going to get your email
// from - whoever you want to be. Just remember that many smtp
// servers will validate the domain of the from address
// before allowing the mail to be sent.
String host = "server.myhost.com";
String to = "YourFriend@somewhere.com";
String from = "MeMeMe@myhost.com";
String subject = "JSP Rules!";
String messageText = "I am sending a message using the"
+ " JavaMail API.\nI can include any text that I want.";
boolean sessionDebug = false;

// Create some properties and get the default Session.
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);

try {

// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(session);

msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);

// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
}
catch (MessagingException mex) {

mex.printStackTrace();
}
}
}

標(biāo)簽:肇慶 保定 廣元 紹興 北海 玉樹 吳忠 潮州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《郵件發(fā)送簡單例子-bean文件》,本文關(guān)鍵詞  郵件,發(fā)送,簡單,例子,-bean,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《郵件發(fā)送簡單例子-bean文件》相關(guān)的同類信息!
  • 本頁收集關(guān)于郵件發(fā)送簡單例子-bean文件的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章