修复读取邮件为空的问题

pull/30/head
taoshihan1991 4 years ago
parent add3f563ea
commit 1563f1dc15

@ -0,0 +1,21 @@
<html lang="cn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="陶士涵">
<title>聊天界面</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<style>
html, body {height: 100%;padding: 0;margin: 0;background-color: #f5f5f5;}
</style>
</head>
<body>
<div id="app">
</div>
</body>
</html>

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="陶士涵">
<title>GO-IMAP网页版邮箱imap工具登录页</title>
<title>GO-FLY登录页</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js"></script>
@ -30,11 +30,11 @@
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
.signin {
width: 100%;
max-width: 400px;
padding: 20px;
margin: auto;
margin:0 auto;
background: #fff;
-webkit-box-shadow: 0 1px 2px 0 rgba(101,129,156,.08);
box-shadow: 0 1px 2px 0 rgba(101,129,156,.08);
@ -43,24 +43,42 @@
</head>
<body class="text-center">
<div id="app" style="width:100%">
<div id="app" class="signin">
<template>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="form-signin">
<h1 class="h3 mb-3 font-weight-normal">邮箱网页版IMAP工具</h1>
<el-form-item prop="server">
<el-input v-model="ruleForm.server" placeholder="IMAP服务器如imap.sina.net:143"></el-input>
</el-form-item>
<el-form-item prop="email">
<el-input v-model="ruleForm.email" placeholder="邮箱地址"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="ruleForm.password" placeholder="密码"></el-input>
</el-form-item>
<el-form-item>
<el-button :loading="loading" type="primary" @click="submitForm('ruleForm')">立即登录</el-button>
<el-button @click="resetForm('ruleForm')">重置</el-button>
</el-form-item>
</el-form>
<h1 class="h3 mb-3 font-weight-normal">登录页</h1>
<el-tabs v-model="activeName">
<el-tab-pane label="本地认证" name="first">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm">
<el-form-item prop="email">
<el-input v-model="ruleForm.email" placeholder="邮箱地址"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="ruleForm.password" placeholder="密码"></el-input>
</el-form-item>
<el-form-item>
<el-button :loading="loading" type="primary" @click="">本地验证</el-button>
<el-button @click="window.location.href='/main'">设置账户</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
<el-tab-pane label="IMAP认证" name="second">
<el-form :model="ruleForm" :rules="rules" ref="ruleForm">
<el-form-item prop="server">
<el-input v-model="ruleForm.server" placeholder="IMAP服务器如imap.sina.net:143"></el-input>
</el-form-item>
<el-form-item prop="email">
<el-input v-model="ruleForm.email" placeholder="邮箱地址"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input v-model="ruleForm.password" placeholder="密码"></el-input>
</el-form-item>
<el-form-item>
<el-button :loading="loading" type="primary" @click="submitForm('ruleForm')">IMAP验证</el-button>
</el-form-item>
</el-form>
</el-tab-pane>
</el-tabs>
<p class="mt-5 mb-3 text-muted">&copy; 2020</p>
</template>
</div>
@ -69,6 +87,8 @@
new Vue({
el: '#app',
data: {
window:window,
activeName:"first",
loading:false,
ruleForm:{
server:'',

@ -166,7 +166,7 @@ func GetMessage(server string, email string, password string, folder string, id
seqSet.AddNum(id)
// Get the whole message body
var section imap.BodySectionName
section:= &imap.BodySectionName{}
items := []imap.FetchItem{section.FetchItem()}
messages := make(chan *imap.Message, 1)
@ -181,23 +181,21 @@ func GetMessage(server string, email string, password string, folder string, id
log.Fatal("Server didn't returned message")
}
r := msg.GetBody(&section)
r := msg.GetBody(section)
if r == nil {
log.Fatal("Server didn't returned message body")
}
var mailitem = new(MailItem)
// Create a new mail reader
mr, err := mail.CreateReader(r)
mr, _ := mail.CreateReader(r)
if err != nil {
return mailitem
}
// Print some info about the message
header := mr.Header
date, _ := header.Date()
log.Println("Date:", date)
mailitem.Date = date.String()
var f string

Loading…
Cancel
Save