本文目錄一覽:
- 1、急java 發送郵件 急!~急!~ 高手快進來幫忙看看啊!~
- 2、求大神解答,我現在想用易語言寫一個轟炸機,在網上看了好多別人的!
- 3、用java寫一個郵件發送代碼
- 4、求一用JAVA做的一個發郵件的程序(急)!
- 5、求一個javaweb郵件收發系統eclipse源代碼,tomcat可以運行的。
急java 發送郵件 急!~急!~ 高手快進來幫忙看看啊!~
這是我的連續發幾封郵件的代碼。連續發是為了163郵箱的積分,^_^。你可以參考下。
package com.test;
import java.io.*;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendEmail extends Authenticator {
public static final String mailuser = “xianlaioy”; // 需要你的郵箱帳號(僅@符號前面的)
public static final String password = “######”; // 需要你的郵箱密碼
private Properties props;
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mailuser, password);
}
public SendEmail(){
props = new Properties();
InputStream is = null;
try {
/*當部署在web容器中時,路徑要修改
* Thread.currentThread().getContextClassLoader().getResource(“”).getPath();
* 得到的url是web容器中的項目下的class路徑
**/
is = new FileInputStream(“src/sendemail.properties”);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
props.load(is);
} catch (IOException e) {
e.printStackTrace();
}
}
/** email為接收郵箱,text為郵件正文
* @throws IOException */
public void sendEamils(String email, String text) throws IOException {
Transport transport = null;
try {
props.setProperty(“mail.smtp.host”, props.getProperty(“mail.smtp.host”));
props.setProperty(“mail.smtp.auth”, props.getProperty(“mail.smtp.auth”));
SendEmail auth = new SendEmail();
javax.mail.Session session = javax.mail.Session.getDefaultInstance(props,
auth);
MimeMessage message = new MimeMessage(session);
Address addressFrom = new InternetAddress(SendEmail.mailuser
+ “@163.com”, “歐陽”);
Address addressTo = new InternetAddress(email, “xianlai”);
message.setText(text);
message.setSubject(“郵件標題”);
message.setFrom(addressFrom);
message.addRecipient(Message.RecipientType.TO, addressTo);
message.saveChanges();
transport = session.getTransport(“smtp”);
session.setDebug(true);
/*transport.connect(“smtp.126.com”, SendEmail.mailuser,
SendEmail.password);*/
transport.send(message);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} finally {
if (transport != null) {
try {
transport.close();
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
}
public static void main(String[] args) {
Timer t = new Timer();
long delay =2*60*1000;
t.schedule(new TimerTask(){
private int count=0;
private SendEmail se=new SendEmail();//作為成員變量就只會創建一個SendEmail對象。
public void run() {
//在timer的run中就必須考慮好怎樣或者什麼時候退出的問題。
//這裡是用count計數的方法來考慮退出的問題的。
if(count++1){
int i=10;
for (int j = 0; j i; j++) {
try {
se.sendEamils(“xianlaioy@126.com”,”test”+j );
} catch (IOException e) {
e.printStackTrace();
}
}
}else {
this.cancel();
System.exit(0);
}
}}, 2000,delay);
}
}
求大神解答,我現在想用易語言寫一個轟炸機,在網上看了好多別人的!
你好,短訊轟炸機寫法非常簡單,post提交就可以了。難就難在要去尋找各大驗證碼的接口,比如某購物網站可以發送驗證碼。我們通過post提交來取得代碼放進軟件裏面,這就算找到了一個驗證碼。
至於轟炸的話當然要很多很多的短訊驗證碼地址,這就要看你耐心去尋找了。
滿意請採納,謝謝!
用java寫一個郵件發送代碼
public boolean mainto()
{
boolean flag = true;
//建立郵件會話
Properties pro = new Properties();
pro.put(“mail.smtp.host”,”smtp.qq.com”);//存儲發送郵件的服務器
pro.put(“mail.smtp.auth”,”true”); //通過服務器驗證
Session s =Session.getInstance(pro); //根據屬性新建一個郵件會話
//s.setDebug(true);
//由郵件會話新建一個消息對象
MimeMessage message = new MimeMessage(s);
//設置郵件
InternetAddress fromAddr = null;
InternetAddress toAddr = null;
try
{
fromAddr = new InternetAddress(451144426+”@qq.com”); //郵件發送地址
message.setFrom(fromAddr); //設置發送地址
toAddr = new InternetAddress(“12345367@qq.com”); //郵件接收地址
message.setRecipient(Message.RecipientType.TO, toAddr); //設置接收地址
message.setSubject(title); //設置郵件標題
message.setText(content); //設置郵件正文
message.setSentDate(new Date()); //設置郵件日期
message.saveChanges(); //保存郵件更改信息
Transport transport = s.getTransport(“smtp”);
transport.connect(“smtp.qq.com”, “451144426”, “密碼”); //服務器地址,郵箱賬號,郵箱密碼
transport.sendMessage(message, message.getAllRecipients()); //發送郵件
transport.close();//關閉
}
catch (Exception e)
{
e.printStackTrace();
flag = false;//發送失敗
}
return flag;
}
這是一個javaMail的郵件發送代碼,需要一個mail.jar
求一用JAVA做的一個發郵件的程序(急)!
這是我以前用的 現在有些需要驗證的郵箱可用用不了,用不了的話HI我
package mail;
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendMail{
public static void main(String[] args) {
send(“標題”,”內容”);
}
public static void send(String h ,String b ) {
try {
Properties p = new Properties(); //Properties p = System.getProperties();
p.put(“mail.smtp.auth”, “true”);
p.put(“mail.transport.protocol”, “smtp”);
p.put(“mail.smtp.host”, “smtp.139.com”);
p.put(“mail.smtp.port”, “25”);
//建立會話
Session session = Session.getInstance(p);
MimeMessage msg = new MimeMessage(session); //建立信息
msg.setFrom(new InternetAddress(“bjyyzx@139.com”)); //發件人
// msg.setRecipient(MimeMessage.RecipientType.TO,
// new InternetAddress(“rewfff@139.com zhu_yajun@139.com”)); //收件人
Address []address=new Address[]{new InternetAddress(“bbb@139.com”),new InternetAddress(“aaa@139.com”)};
msg.setRecipients(MimeMessage.RecipientType.TO,
address); //收件人
msg.setSentDate(new Date()); // 發送日期
msg.setSubject(h); // 主題
msg.setText(b); //內容
// 郵件服務器進行驗證
Transport tran = session.getTransport(“smtp”);
tran.connect(“smtp.139.com”, “bluebit_cn”, “xiaohao”);
// bluebit_cn是用戶名,xiaohao是密碼
tran.sendMessage(msg, msg.getAllRecipients()); // 發送
//System.out.println(“郵件發送成功”);
} catch (Exception e) {
e.printStackTrace();
}
}}
求一個javaweb郵件收發系統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發送郵件的5個步驟
//1、創建session
Session session = Session.getInstance(prop);
//開啟Session的debug模式,這樣就可以查看到程序發送Email的運行狀態
session.setDebug(true);
//2、通過session得到transport對象
Transport ts = session.getTransport();
//3、使用郵箱的用戶名和密碼連上郵件服務器,發送郵件時,發件人需要提交郵箱的用戶名和密碼給smtp服務器,用戶名和密碼都通過驗證之後才能夠正常發送郵件給收件人。
ts.connect(“smtp.sohu.com”, “gacl”, “郵箱密碼”);
//4、創建郵件
Message message = createSimpleMail(session);
//5、發送郵件
ts.sendMessage(message, message.getAllRecipients());
ts.close();
}
/**
* @Method: createSimpleMail
* @Description: 創建一封只包含文本的郵件
* @param session
* @return
* @throws Exception
*/
public static MimeMessage createSimpleMail(Session session)
throws Exception {
//創建郵件對象
MimeMessage message = new MimeMessage(session);
//指明郵件的發件人
message.setFrom(new InternetAddress(“gacl@sohu.com”));
//指明郵件的收件人,現在發件人和收件人是一樣的,那就是自己給自己發
message.setRecipient(Message.RecipientType.TO, new InternetAddress(“gacl@sohu.com”));
//郵件的標題
message.setSubject(“只包含文本的簡單郵件”);
//郵件的文本內容
message.setContent(“你好啊!”, “text/html;charset=UTF-8”);
//返回創建好的郵件對象
return message;
}
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/227329.html