사용자가 연락처 양식을 제출 한 후 nodemailer를 사용하여 전자 메일을 보내면 사용자는 감사 페이지로 이동합니다. 나는 cloud9에서이 프로젝트를 작업했다. 여기에 내 코드 :이메일을 보낸 후 Nodemailer가 매우 느림
이메일이 성공적으로 발송 될 수 있으며, 내가 양식을 제출 한 후 몇 초에서 볼 수 있지만, 페이지가 몇 가지 오류를 표시 할 때까지로드를 영원히 유지할
var express = require("express"),
bodyParse = require("body-parser"),
multer = require("multer"),
nodemailer = require("nodemailer");
var app = express();
app.use(bodyParse.urlencoded({extended: true}));
var smtpTransport = nodemailer.createTransport({
service: "Gmail",
auth: {
type: "OAuth2",
user: "[email protected]",
clientId: "xxxxxx",
clientSecret: "xxxxx",
refreshToken: "xxxxx",
accessToken: "xxxxx"
}
});
app.post("/upload", function(req, res){
var mailOptions = {
from: "xxxx <[email protected]", // sender address
to: "[email protected]", // list of receivers
subject: "xxxx", // Subject line
text: "xxxx",
attachments: [
{ // file on disk as an attachment
filename: 'xxxx.txt',
path: './uploads/' + req.body.filename // stream this file
}
]
};
// send mail with defined transport object
smtpTransport.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
})
(I가 부착 된 아래의 오류 메시지 참조). 이 기간 동안, 나는 하나 또는 두 개의 동일한 이메일을 받게됩니다.
<html>
<head>
<meta charset='utf-8'>
<title>Error 502 - Bad Gateway</title>
<link rel="stylesheet" type="text/css"
href="https://cdn.c9.io/errors/style.css" />
<style type="text/css">
.error_content {
background: rgba(255, 255, 255, 0.23);
padding: 10px;
width: 641px;
margin: 25px 0;
display: none;
}
#error-msg {
display: block;
}
</style>
</head>
<body class="errorUnknown light">
<div id="wrapper">
<h1>Error 502 - Bad Gateway</h1>
<div class="error_content" id="error-msg">
<p>Please click <a href="javascript:location.reload(true)">here</a> to try again, if the issue persists please contact <a href="https://c9.io/support">support</a></p>
</div>
<a href="http://status.c9.io">Status Page</a> |
<a href="https://c9.io/support">Support</a> |
<a href="https://c9.io/dashboard.html">Dashboard</a> |
<a href="https://c9.io">Home</a>
</div>
</body>
</html>
QQQQQ :이 문제를 해결하려면 어떻게해야합니까? QQQQQ : 내 코드 또는 cloud9 서버의 문제입니까?
고마워, 그게 문제 야. – simonhb1990
알려 주셔서 감사합니다. – simonhb1990