java群发发送qq邮件
java是常用的编程语言之一,我们可以利用java来做很多事情,甚至可以用于邮件群发,今天一米软件就来教教大家java群发发送qq邮件怎么做。
1、开启SMTP服务
在 QQ 邮箱里的 设置->账户里开启 SMTP 服务
注意开启完之后,QQ 邮箱会生成一个授权码,在代码里连接邮箱使用这个授权码而不是原始的邮箱密码,这样可以避免使用明文密码。
2、下载依赖的 jar 包
官方下载地址 http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.7-oth-JPR。
解压完之后,通常我们只需要其中的mail.jar,把它加到 工程的依赖包中。
3、完整代码示例
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import com.sun.mail.util.MailSSLSocketFactory;
public class MailTool {
public static void main(String[] args) throws MessagingException, GeneralSecurityException {
Properties props = new Properties();
// 开启debug调试
props.setProperty("mail.debug", "true");
// 发送服务器需要身份验证
props.setProperty("mail.smtp.auth", "true");
// 设置邮件服务器主机名
props.setProperty("mail.host", "smtp.qq.com");
// 发送邮件协议名称
props.setProperty("mail.transport.protocol", "smtp");
//开启了 SSL 加密
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session);
msg.setSubject("seenews 错误");
StringBuilder builder = new StringBuilder();
builder.append("url = " + "http://blog.csdn.net/never_cxb/article/details/50524571");
builder.append(" 页面爬虫错误");
builder.append(" 时间 " + new Date());
msg.setText(builder.toString());
msg.setFrom(new InternetAddress("发送人的邮箱地址"));//**发送人的邮箱地址**
Transport transport = session.getTransport();
transport.connect("smtp.qq.com","发送人的邮箱地址","你的邮箱授权码");
List list=new ArrayList<>();
//实现群发,下面的方法也是可以实现群发,但是不太理想
transport.sendMessage(msg, InternetAddress.parse("3306907224@qq.com,269056581@qq.com"));
/*transport.sendMessage(msg, new Address[] {
new InternetAddress("3306907224@qq.com"),
new InternetAddress("269056581@qq.com"),
new InternetAddress("zhengmm@gz2000.net")
}
);*/
transport.close();
}
}
上一条:新浪邮箱怎么群发qq邮件
下一条:不是好友怎么群发qq邮件
-
qq邮箱群发可以投几次
做邮件群发数量很重要,发的越多成功的概率才会越大,下面一米软件就来和大家说说qq邮箱群发可以投几次...
2019-12-09 14:36:31 阅读:3513 #网络营销#
-
推动力网 qq邮箱群发
推动力网的V动力QQ邮箱群发大师是采用HTTP协议,即网页POST,像我们打开网页发邮件时数据是通...
2019-12-09 14:51:24 阅读:3024 #网络营销#
-
QQ邮箱群发邮件发不出
QQ邮箱群发邮件发不出是一件让人头疼的事情,今天一米软件就来告诉大家遇到QQ邮箱群发邮件发不出的情...
2019-12-09 15:01:44 阅读:4381 #网络营销#
-
qq邮箱群发邮件给好友
给qq好友群发邮件是很多人经常要做的事情,可还是有些人不清楚具体该怎么做,下面一米软件就来告诉大家...
2019-12-09 15:12:36 阅读:4185 #网络营销#
-
易连qq邮箱群发
QQ邮箱群发软件是款针对QQ邮箱的辅助群发工具。用户可以通过这款软件进行QQ邮箱的内容群发,非常适...
2019-12-09 15:18:45 阅读:2846 #网络营销#
热门推荐
- 1怎么利用Facebook赚钱阅读:4609
- 2电子邮件营销的策略 阅读:4144
- 3邮箱群发不进垃圾箱阅读:4509
- 4群发邮箱平台哪个好 阅读:4311
- 5邮件推广中的具体营销步骤阅读:4451
- 6如何群发邮件但不被发现阅读:5292
- 7群发邮件如何不屏蔽阅读:3075
- 8邮件如何群发多个不同的人阅读:3202
- 9哪个邮箱群发效果好阅读:3035
- 10如何群发邮件阅读:3195
- 11电子邮件的营销方法 阅读:3028
- 12电子邮件杂志营销 阅读:3019
- 13电子邮件广告样式阅读:3130
- 14邮件批量发送软件 阅读:3209
- 15外贸邮件群发阅读:2953
- 16哪个邮箱群发效果好阅读:2958
- 17邮件推广的技巧阅读:3120
- 18邮件如何群发阅读:2976
- 19facebook 怎么增加好友阅读:3209
- 20如何可以群发邮件 阅读:3121
- 21邮件广告投放渠道有哪些阅读:3463
- 22批量群发邮件 阅读:3070
- 23怎么发广告邮件阅读:3303
- 24邮件批量发送系统使用方法阅读:3038
- 25群发邮件数量限制阅读:3557
- 26批量发送个性化邮件阅读:3148
- 27邮件怎么群发给很多人阅读:2980
- 28如何自动发广告邮件阅读:3277
- 29如何群发邮件阅读:75451
- 30邮件如何发给多人阅读:75707
标签更多+