當前位置:首頁 » 網頁前端 » javaweb郵件發送
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

javaweb郵件發送

發布時間: 2022-05-05 04:51:11

㈠ JavaWeb注冊發送郵件

將發送郵件的代碼寫在一個線程裡面

㈡ java web發送郵件發生異常

mailInfo.setUserName("[email protected]");

mailInfo.setUserName("han2000lei");
試試?

㈢ javaWeb郵箱問題

用java mail包實現。在後台創建一個功能,群發郵件,當有需要時,登陸後台,寫完郵件,直接點群發就行了。前提是資料庫中存有用戶的郵箱。下面是java mail的示例。你可以買本相關的書看看,也可以在網上找一些資料。很多的。

使用java發送郵件

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

public class SendMail {
public SendMail() {
}

public static void main(String[] args) {
try {
Authenticator auth = new PopupAuthenticator();
Properties mailProps = new Properties();
mailProps.put("mail.smtp.host", "smtp.163.com");
mailProps.put("mail.smtp.auth", "true");
mailProps.put("username", "pyrgz");
mailProps.put("password", "123456789");
Session mailSession = Session.getDefaultInstance(mailProps, auth);
MimeMessage message = new MimeMessage(mailSession);
message.setFrom(new InternetAddress("[email protected]"));
message.setRecipient(Message.RecipientType.TO, new InternetAddress(
"[email protected]"));
message.setSubject("Mail Test");
MimeMultipart multi = new MimeMultipart();
BodyPart textBodyPart = new MimeBodyPart();
textBodyPart.setText("Hello World!");
multi.addBodyPart(textBodyPart);
message.setContent(multi);
message.saveChanges();
Transport.send(message);
} catch (Exception ex) {
System.err.println("郵件發送失敗的原因是:" + ex.getMessage());
System.err.println("具體錯誤原因:");
ex.printStackTrace(System.err);
}
}
}

class PopupAuthenticator extends Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
String username = "pyrgz"; // 163郵箱登錄帳號
String pwd = "123456789"; // 登錄密碼
return new PasswordAuthentication(username, pwd);
}
}

㈣ 求一個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("[email protected]"));
//指明郵件的收件人,現在發件人和收件人是一樣的,那就是自己給自己發
message.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
//郵件的標題
message.setSubject("只包含文本的簡單郵件");
//郵件的文本內容
message.setContent("你好啊!", "text/html;charset=UTF-8");
//返回創建好的郵件對象
return message;
}
}

㈤ java web發送郵件里包含動態超鏈接該怎麼實現

首先選中介面類型名字,右鍵菜單,如圖

這樣你就能輕松查看有哪些類實現該介面

該方法不僅僅適用介面,也可以查找某個類的子父級關系

㈥ java web使用 用MS的exchange郵件伺服器發送郵件

我說你這種想法不對!
我不能給你提供具體的解決方案,我給你一個思路!
首先你需要Exchange 200x 中配置 SMTP 連接器;
然後使用JAVA的mail包寫發郵件的程序。

㈦ java web 項目發送帶有超鏈接文本郵件問題

首先需要設置郵件內容的格式為:html

其次在內容中加上<a href='your url' 即可;

String html =

㈧ java web怎樣實現在自己做的系統中郵件發送或者通信

如果是做普通的收發消息,就做個簡單的查庫那種就可以了
如果要做mail,要有個mail伺服器,然後利用SMTP和POP3協議進行收發操作
如果是即時通信 可以在頁面里潛入socket程序,也可以做實時動態刷新那種,ajax