iPad和iPhone都限制电脑只能收发邮件邮件不能发,第一:我账户密码都正确第二:pops,imap,smtp这些是开了的!已经开了

已使用 163 邮箱测试通过,且支持 SSL 连接。
示例:Jack 发送一封邮件给 Rose。
public class SendMail {
& & public static void main(String[] args) {
& & & & boolean isSSL =
& & & & String host = "";
& & & & int port = 465;
& & & & String from = "";
& & & & String to = "";
& & & & boolean isAuth =
& & & & final String username = "";
& & & & final String password = "jack";
& & & & Properties props = new Properties();
& & & & props.put("mail.smtp.ssl.enable", isSSL);
& & & & props.put("mail.smtp.host", host);
& & & & props.put("mail.smtp.port", port);
& & & & props.put("mail.smtp.auth", isAuth);
& & & & Session session = Session.getDefaultInstance(props, new Authenticator() {
& & & & & & @Override
& & & & & & protected PasswordAuthentication getPasswordAuthentication() {
& & & & & & & & return new PasswordAuthentication(username, password);
& & & & & & }
& & & & });
& & & & try {
& & & & & & Message message = new MimeMessage(session);
& & & & & & message.setFrom(new InternetAddress(from));
& & & & & & message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
& & & & & & message.setSubject("主题");
& & & & & & message.setText("内容");
& & & & & & Transport.send(message);
& & & & } catch (AddressException e) {
& & & & & & e.printStackTrace();
& & & & } catch (MessagingException e) {
& & & & & & e.printStackTrace();
& & & & System.out.println("发送完毕!");
示例:Rose 收取最近一封邮件。
import java.util.D
import java.util.P
import javax.mail.F
import javax.mail.M
import javax.mail.MessagingE
import javax.mail.NoSuchProviderE
import javax.mail.S
import javax.mail.S
public class FetchMail {
public static void main(String[] args) {
String protocol = "pop3";
boolean isSSL =
String host = "";
int port = 995;
String username = "";
String password = "rose";
Properties props = new Properties();
props.put("mail.pop3.ssl.enable", isSSL);
props.put("mail.pop3.host", host);
props.put("mail.pop3.port", port);
Session session = Session.getDefaultInstance(props);
Store store =
Folder folder =
store = session.getStore(protocol);
store.connect(username, password);
folder&= store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
int size = folder.getMessageCount();
Message message = folder.getMessage(size);
String from = message.getFrom()[0].toString();
String subject = message.getSubject();
Date date = message.getSentDate();
System.out.println("From: " + from);
System.out.println("Subject: " + subject);
System.out.println("Date: " + date);
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} finally {
if (folder&!= null) {
folder.close(false);
if (store != null) {
store.close();
} catch (MessagingException e) {
e.printStackTrace();
System.out.println("接收完毕!");
常用邮件协议
发送邮件:SMTP
收取邮件:POP3、IMAP
常用邮件配置项
mail.xxx.ssl.enable
是否支持 SSL 连接
mail.xxx.host
邮件服务器主机名
mail.xxx.port
邮件服务器端口号
mail.xxx.auth
是否进行身份认证
说明:xxx 表示协议名称,例如:smtp、pop3 等。
默认端口号
使用 Apache Commons Email 发送邮件
import mons.mail.E
import mons.mail.EmailE
import mons.mail.SimpleE
public class SendMail {
public static void main(String[] args) {
boolean isSSL =
String host = "";
int port = 465;
String from = "";
String to = "";
String username = "";
String password = "jack";
Email email = new SimpleEmail();
email.setSSLOnConnect(isSSL);
email.setHostName(host);
email.setSmtpPort(port);
email.setAuthentication(username, password);
email.setFrom(from);
email.addTo(to);
email.setSubject("主题");
email.setMsg("内容");
email.send();
} catch (EmailException e) {
e.printStackTrace();
System.out.println("发送完毕!");
确实是写反了,阅读了 1429 次,终于被兄弟发现了这个 bug,看来该 bug 藏得足够深啊。
& 开源中国(OSChina.NET) |
开源中国社区(OSChina.net)是工信部
指定的官方社区The page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.我用的是Microsoft outlook,只能收邮件,不能发邮件,这是为什么?_百度知道The page is temporarily unavailable
nginx error!
The page you are looking for is temporarily unavailable.
Please try again later.
Website Administrator
Something has triggered an error on your
This is the default error page for
nginx that is distributed with
It is located
/usr/share/nginx/html/50x.html
You should customize this error page for your own
site or edit the error_page directive in
the nginx configuration file
/etc/nginx/nginx.conf.

我要回帖

更多关于 手机只能显示一封邮件 的文章

 

随机推荐