一、 QQ 郵箱 2
二、 搜狐郵箱 8
三、 139 郵箱 14
四、 163 郵箱 19
五、 126 郵箱 22
一、 QQ 郵箱
1、mail.qq.com 輸入用戶名密碼登陸
2、點(diǎn)擊頁面【設(shè)置】所在位置,進(jìn)入設(shè)置頁面
3、進(jìn)入【賬戶】選項卡, POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV 服務(wù)頁面, 開啟 POP3 與 IMAP 服務(wù)。
4、如未綁定手機(jī)安全令牌,按提示發(fā)送短信,發(fā)送后點(diǎn)擊“我已發(fā)送”即可
5、將授權(quán)碼復(fù)制出來,備用。
6、如已綁定手機(jī)安全令牌,操作如下
7、獲取第三方授權(quán)碼作為第三方登陸密碼使用
獲取授權(quán)碼
8、點(diǎn)擊生成授權(quán)碼,輸入圖中手機(jī)安全令牌的動態(tài)密碼
9、查看手機(jī)的安全令牌(手機(jī)軟件名字為 QQ 安全中心, 需手機(jī)下載使用)
10、輸入圖中的安全令牌,生成第三方登陸密碼
11、填寫相關(guān)信息至郵件發(fā)送設(shè)置(注意圖中密碼不是郵箱密碼, 是第三方客戶 端授權(quán)碼)
二、 搜狐郵箱
1、mail.sohu.com 輸入用戶名密碼登陸
2、點(diǎn)擊頁面上方【選項】按鈕,點(diǎn)擊【設(shè)置】
3、點(diǎn)擊進(jìn)入【POP/IMAP/SMTP】頁面, 勾選開啟 POP3/SMTP 服務(wù)和 IMAP4/SMTP 服務(wù)
4、初次進(jìn)入,點(diǎn)擊“保存”后,彈出手機(jī)驗證, 輸入驗證碼,點(diǎn)擊確定獲取授 權(quán)碼。若曾獲取獨(dú)立密碼(授權(quán)碼),點(diǎn)擊重置獨(dú)立密碼,后續(xù)步驟相同。
5、將授權(quán)碼復(fù)制出來,備用
6、填寫相關(guān)信息至郵件發(fā)送設(shè)置(注意圖中密碼不是郵箱密碼,是第三方客戶 端授權(quán)碼)
三、 139 郵箱
1、mail.139.com 輸入用戶名密碼登陸
2、進(jìn)入頁面若為 3.0 版本,需要點(diǎn)擊【升級版本6.0】。
3、點(diǎn)擊頁面右上角齒輪圖標(biāo),點(diǎn)擊【賬戶信息】,進(jìn)入設(shè)置頁面
4、進(jìn)入【設(shè)置】頁面,分別勾選開啟 POP3/SMTP 服務(wù)和 IMAP/SMTP 服務(wù),點(diǎn)擊 【保存】按鈕。
5、點(diǎn)擊【生成授權(quán)碼】,彈出彈框,錄入驗證碼,點(diǎn)擊【確定】按鈕。
6、將此“客戶端授權(quán)碼”復(fù)制出來,備用
5、若曾獲取授權(quán)碼, 可點(diǎn)擊【查看】、【重置】、【刪除】按鈕, 重新獲取授權(quán)碼。
6、填寫相關(guān)信息至郵件發(fā)送設(shè)置(注意圖中密碼不是郵箱密碼,是第三方客戶 端授權(quán)碼)
四、 163 郵箱
1、mail.163.com 輸入用戶名密碼登陸
2、點(diǎn)擊頁面上方【設(shè)置】按鈕,點(diǎn)擊【POP/IMAP/SMTP】
3、將頁面中 POP3/SMTP 服務(wù)和 IMAP4/SMTP 服務(wù)全部開啟, 發(fā)送短信后, 將授權(quán) 碼復(fù)制出來。
6、填寫相關(guān)信息至郵件發(fā)送設(shè)置(注意圖中密碼不是郵箱密碼,是第三方客戶 端授權(quán)碼)
五、 126 郵箱
1、mail.126.com 輸入用戶名密碼登陸
2、點(diǎn)擊頁面上方【設(shè)置】按鈕,點(diǎn)擊【POP/IMAP/SMTP】
3、將頁面中 POP3/SMTP 服務(wù)和 IMAP4/SMTP 服務(wù)全部開啟, 發(fā)送短信后, 將授權(quán) 碼復(fù)制出來。
4、填寫相關(guān)信息至郵件發(fā)送設(shè)置(注意圖中密碼不是郵箱密碼,是第三方客戶 端授權(quán)碼)
本文來源:本文收集整理于網(wǎng)絡(luò)
聲明:本文僅供交流學(xué)習(xí),版權(quán)歸屬原作者,若來源標(biāo)注錯誤或侵犯到您的權(quán)益,煩請告知,我們將立即刪除,謝謝
編輯:sometime
編制:2023年06月29日
、在電腦端“注冊免費(fèi)郵箱”
我們大多會需要使用電子郵箱,如何在電腦端“注冊免費(fèi)郵箱”,如何在手機(jī)端登錄在電腦端已注冊的電子郵箱、用手機(jī)發(fā)送電子郵件及與電腦端電子郵箱同步接收電子郵件?這里為初次使用者,以我用過的、在電腦端注冊過的一款免費(fèi)郵箱,及兩款手機(jī)登錄在電腦端已注冊的電子郵箱為例,簡單介紹其中的一種注冊、及手機(jī)添加已注冊電子郵箱賬戶的方法:
1、開電腦,連接網(wǎng)絡(luò),打開將要“注冊免費(fèi)郵箱”的網(wǎng)頁,點(diǎn)擊右上角的“注冊免費(fèi)郵箱”,見圖1打開的網(wǎng)頁、圖2郵箱注冊頁面。
圖1 打開的網(wǎng)頁
圖2 郵箱注冊頁面
2、在圖2,選擇“普通注冊”,按提示設(shè)置、輸入:電子郵箱地址(電子郵箱賬戶、電子郵件地址、用戶名)。
電子郵箱地址為6∽18個字符,可使用字母、數(shù)字,下劃線,需要以字母開頭。
輸入電子郵箱地址后,系統(tǒng)會檢查你輸入的電子郵箱地址是否已經(jīng)被別人使用,如已經(jīng)被占用、需修改地址。
按提示輸入密碼、手機(jī)號碼,并“獲取驗證碼”、輸入驗證碼,勾選同意《服務(wù)條款》、點(diǎn)擊“立即注冊”。
“注冊免費(fèi)郵箱”完成。
也可以用手機(jī)號碼做電子郵箱地址,快速注冊電子郵箱,按提示設(shè)置、輸入即可。
圖3 已“注冊免費(fèi)郵箱”,并已登錄
3、點(diǎn)擊圖3郵箱頁面上方的“設(shè)置”,切換為圖4,
圖4 郵箱安全設(shè)置
4、點(diǎn)擊圖4郵箱頁面左側(cè)的“郵箱安全設(shè)置”,找到“安全驗證場景”,勾選“登錄二次驗證”,這樣在電腦登錄電子郵箱時,需要登錄密碼、同時需要手機(jī)的短信驗證碼才能登錄,增加了電子郵箱的安全性,見圖5。
圖5 登錄電子郵箱 需輸入短信驗證碼
5、點(diǎn)擊圖4郵箱頁面左側(cè)的“POP3/SMTP/IMAP”,切換為圖6,找到“POP3/SMTP/IMAP”的“開啟服務(wù):”,
IMAP /SMTP服務(wù) 選擇“開啟”
POP3/SMTP服務(wù) 選擇“開啟”
為在手機(jī)端設(shè)置登錄該電子郵箱提供“開啟服務(wù)”,見圖6。
圖6 POP3/SMTP/IMAP 設(shè)置
6、在圖6,找到“POP3/SMTP/IMAP”的“授權(quán)密碼管理:”(授權(quán)碼是用于登錄第三方郵箱的專用密碼),每個賬號最多設(shè)置5個授權(quán)密碼。
點(diǎn)擊“新增授權(quán)密碼”可為手機(jī)登錄該電子郵箱生成專用密碼,手機(jī)添加電子郵箱時需要輸入該專用密碼,您如果有兩臺手機(jī)需要登錄該電子郵箱,則需要分別生成兩個不同的專用密碼,見圖6,見圖11,見圖16。
點(diǎn)擊“新增授權(quán)密碼”,會彈出二維碼,需用注冊電子郵箱的手機(jī),按提示掃描二維碼、進(jìn)行“賬號安全驗證”。
在“授權(quán)密碼管理:”手機(jī)成功添加電子郵箱后(如:設(shè)備1,啟用時間2018.12.20),如需要解除手機(jī)的登錄權(quán)限,在這里點(diǎn)擊“刪除”即可。
也可以在:
IMAP /SMTP服務(wù) 選擇“關(guān)閉”
POP3/SMTP服務(wù) 選擇“關(guān)閉”
即可關(guān)閉手機(jī)登錄郵箱服務(wù)。
二、在手機(jī)端添加、在電腦端已經(jīng)注冊的電子郵箱
1、手機(jī)A
⑴打開手機(jī)“設(shè)置”,點(diǎn)擊“郵件”,見圖7。
圖7 設(shè)置
⑵點(diǎn)擊“郵件”的“賬戶”,見圖8。
圖8 郵件
⑶點(diǎn)擊“賬戶”的“添加賬戶”,見圖9。
圖9 賬戶
⑷點(diǎn)擊“添加賬戶”的 你要添加的賬戶,見圖10。
圖10 添加賬戶
⑸在圖11,按提示輸入:在電腦端已經(jīng)注冊的、電子郵箱地址(電子郵箱賬戶、電子郵件地址、用戶名),及圖6的“新增授權(quán)密碼”生成的“專用密碼”,點(diǎn)擊“下一步”。
圖11
⑹在圖12,點(diǎn)擊“完成”,手機(jī)即可利用在電腦端注冊的免費(fèi)郵箱、發(fā)送電子郵件,并可與電腦端電子郵箱同步接收電子郵件,見圖12。
圖12
2、手機(jī)B
⑴打開手機(jī)“設(shè)置”,點(diǎn)擊“應(yīng)用和服務(wù)”,見圖13。
圖13 設(shè)置
⑵點(diǎn)擊“應(yīng)用和服務(wù)”的“電子郵件”,見圖14。
圖14 應(yīng)用和服務(wù)
⑶點(diǎn)擊“電子郵件”的“添加賬戶”,見圖15。
圖15 電子郵件
⑷在圖16 ,“賬戶登錄”里按提示輸入:在電腦端已經(jīng)注冊的、電子郵箱地址(電子郵箱賬戶、電子郵件地址、用戶名),及圖6的“新增授權(quán)密碼”生成的“專用密碼”,點(diǎn)擊“登錄”。
圖16 賬戶登錄
⑸在圖17,點(diǎn)擊“完成”,手機(jī)即可利用在電腦端注冊的免費(fèi)郵箱、發(fā)送電子郵件,并可與電腦端電子郵箱同步接收電子郵件,見圖17。
圖17 服務(wù)器設(shè)置
3、在手機(jī)端添加電子郵箱之后,在手機(jī)端打開該電子郵箱不需要輸入密碼。
手機(jī)成功添加電子郵箱后,可在手機(jī)端“刪除賬戶”,解除手機(jī)端登錄電子郵箱。
這是一個使用spring boot做的一個qq郵箱注冊和登錄的項目。
沒寫前端頁面,使用postman測試。有截圖詳細(xì)。
注冊:通過輸入的郵箱發(fā)送驗證碼,檢驗前端傳來的驗證碼是否和后臺生成的一致,若一致,將數(shù)據(jù)寫入數(shù)據(jù)庫,完成注冊;
登錄:通過輸入的郵箱查詢密碼,然后比較密碼是否一致,一致就是登錄成功。
登錄qq郵箱后,點(diǎn)擊左上方的設(shè)置,選擇賬戶,如下圖。
然后一直往下滑,看到如下圖的POP3/SMTP服務(wù),點(diǎn)擊開啟,應(yīng)該會讓幫定的手機(jī)號發(fā)個短信,然后會收到一個授權(quán)碼,一定要好好保存,在appliction.properties配置中會用到。
下邊是pom.xml中<dependencies>標(biāo)簽的全部依賴
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<!--jdbc-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
application.properties配置文件
#郵箱配置
#平臺地址,這里用的是qq郵箱,使用其他郵箱請更換
spring.mail.host=smtp.qq.com
#改成自己的郵箱
spring.mail.username=xxxxx@qq.com
#發(fā)送短信后它給你的授權(quán)碼 填寫到這里
spring.mail.password=xxxxxx
#這東西不用改
spring.mail.properties.mail.smtp.ssl.enable=true
##編碼格式
spring.mail.default-encoding=UTF-8
#數(shù)據(jù)庫相關(guān)配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/email?useSSL=true&characterEncoding=utf-8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
#配置mapper
mybatis.mapper-locations=classpath:mapper/*.xml
數(shù)據(jù)庫結(jié)構(gòu)如下圖
創(chuàng)建一個數(shù)據(jù)庫email
CREATE DATABASE email;
在email數(shù)據(jù)庫創(chuàng)建user表
CREATE TABLE `user` (
`id` int(20) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
如最上邊的項目結(jié)構(gòu)圖。controller包是和前端對接的,mapper包中是接口,pojo是實(shí)體類,service層是邏輯代碼,vo包是前端發(fā)送數(shù)據(jù)暫時保存。
執(zhí)行流程: 使用postman發(fā)送請求,controller中會接受,然后調(diào)用service中的邏輯代碼,service會調(diào)用的mapper中接口,mapper的對應(yīng)的xml實(shí)現(xiàn)對數(shù)據(jù)庫的各種操作。
3.1、UserController.java
package com.lu.youxiang.controller;
import com.lu.youxiang.service.MailService;
import com.lu.youxiang.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
@Controller
public class UserController {
@Autowired
private MailService mailService;
@PostMapping("/sendEmail")
@ResponseBody
public String sendEmail(String email, HttpSession httpSession){
mailService.sendMimeMail(email, httpSession);
return "sucess";
}
@PostMapping("/regist")
@ResponseBody
public String regist(UserVo userVo, HttpSession session){
mailService.registered(userVo,session);
return "sucess";
}
@PostMapping("/login")
@ResponseBody
public String login(String email, String password){
mailService.loginIn(email,password);
return "sucess";
}
}
3.2、UserMapper.java
package com.lu.youxiang.mapper;
import com.lu.youxiang.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface UserMapper {
/**
* 注冊,插入數(shù)據(jù)
* @param user
*/
void insertUser(User user);
/**
* 根據(jù)郵箱查詢
* @param email
* @return
*/
User queryByEmail(String email);
}
3.3、User.java
package com.lu.youxiang.pojo;
public class User {
private String username;
private String password;
private String email;
//get和set方法省略了,自己生成一下
}
3.4、MailService.java ,重要。
package com.lu.youxiang.service;
import com.lu.youxiang.mapper.UserMapper;
import com.lu.youxiang.pojo.User;
import com.lu.youxiang.vo.UserVo;
import com.lu.youxiang.vo.UserVoToUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.util.Random;
@Service
public class MailService {
@Autowired
private JavaMailSender mailSender;//一定要用@Autowired
@Autowired
private UserMapper userMapper;//注入UserMapper,交給bena
//application.properties中已配置的值
@Value("${spring.mail.username}")
private String from;
/**
* 給前端輸入的郵箱,發(fā)送驗證碼
* @param email
* @param session
* @return
*/
public boolean sendMimeMail( String email, HttpSession session) {
try {
SimpleMailMessage mailMessage=new SimpleMailMessage();
mailMessage.setSubject("驗證碼郵件");//主題
//生成隨機(jī)數(shù)
String code=randomCode();
//將隨機(jī)數(shù)放置到session中
session.setAttribute("email",email);
session.setAttribute("code",code);
mailMessage.setText("您收到的驗證碼是:"+code);//內(nèi)容
mailMessage.setTo(email);//發(fā)給誰
mailMessage.setFrom(from);//你自己的郵箱
mailSender.send(mailMessage);//發(fā)送
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
}
/**
* 隨機(jī)生成6位數(shù)的驗證碼
* @return String code
*/
public String randomCode(){
StringBuilder str=new StringBuilder();
Random random=new Random();
for (int i=0; i < 6; i++) {
str.append(random.nextInt(10));
}
return str.toString();
}
/**
* 檢驗驗證碼是否一致
* @param userVo
* @param session
* @return
*/
public boolean registered(UserVo userVo, HttpSession session){
//獲取session中的驗證信息
String email=(String) session.getAttribute("email");
String code=(String) session.getAttribute("code");
//獲取表單中的提交的驗證信息
String voCode=userVo.getCode();
//如果email數(shù)據(jù)為空,或者不一致,注冊失敗
if (email==null || email.isEmpty()){
//return "error,請重新注冊";
return false;
}else if (!code.equals(voCode)){
//return "error,請重新注冊";
return false;
}
//保存數(shù)據(jù)
User user=UserVoToUser.toUser(userVo);
//將數(shù)據(jù)寫入數(shù)據(jù)庫
userMapper.insertUser(user);
//跳轉(zhuǎn)成功頁面
return true;
}
/**
* 通過輸入email查詢password,然后比較兩個password,如果一樣,登錄成功
* @param email
* @param password
* @return
*/
public boolean loginIn(String email, String password){
User user=userMapper.queryByEmail(email);
if(!user.getPassword().equals(password)){
return false;
}
System.out.println("登錄成功:數(shù)據(jù)庫密碼是:"+user.getPassword());
return true;
}
}
3.5、UserVo.java
package com.lu.youxiang.vo;
public class UserVo {
private String username;
private String password;
private String email;
// 驗證碼
private String code;
//省略了get和set方法,自己生成一下
}
3.6、UserVoToUser.java
package com.lu.youxiang.vo;
import com.lu.youxiang.pojo.User;
public class UserVoToUser {
/**
* 將表單中的對象轉(zhuǎn)化為數(shù)據(jù)庫中存儲的用戶對象(剔除表單中的code)
* @param userVo
* @return
*/
public static User toUser(UserVo userVo) {
//創(chuàng)建一個數(shù)據(jù)庫中存儲的對象
User user=new User();
//傳值
user.setUsername(userVo.getUsername());
user.setPassword(userVo.getPassword());
user.setEmail(userVo.getEmail());
// 返回包裝后的對象
return user;
}
}
主配置類不復(fù)制了,創(chuàng)建springboot項目后,就有。
3.7、UserMapper.xml
在resources包下創(chuàng)建mapper包,用來放xml,然后再這個包中創(chuàng)建UserMapper.xml,內(nèi)容如下。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lu.youxiang.mapper.UserMapper">
<insert id="insertUser" parameterType="com.lu.youxiang.pojo.User">
insert into user (username,password,email)
values (#{username},#{password},#{email})
</insert>
<select id="queryByEmail" resultType="com.lu.youxiang.pojo.User">
select *
from user
where email=#{email}
</select>
</mapper>
如果沒有這個軟件,安裝一下,使用很簡單。
打開后,點(diǎn)擊左上角的file,再點(diǎn)擊New Tab,就會出來一個頁面。
(或者使用Ctrl+T快捷鍵)
請求url:
http://localhost:8080/sendEmail?email=123456@qq.com
把請求url復(fù)制到如下如的url中, 郵箱換成自己的,請求方式換成POST。點(diǎn)擊send。
如下圖
請求url:
http://localhost:8080/regist
把請求url復(fù)制到如下如的url中, 郵箱換成自己的,code的值寫郵箱收到的,請求方式換成POST。點(diǎn)擊send,如下圖
請求url:
http://localhost:8080/login?email=123456@qq.com&password=12345
復(fù)制url,改成POST請求,點(diǎn)擊Send。
如下圖:
轉(zhuǎn)載自:https://mp.weixin.qq.com/s/JnLzmcNO7IuP78qfDUXE_Q