javascript - 邮件客户端无法联系 smtp 服务器(用 C++ 编写)
问题描述
我的 smtp 服务器是用 C++ 编写的。邮件客户端采用 HTML 和 JS 格式。我使用 smtpjs 库来发送邮件。用于 Web 服务器的 Apache。但是,邮件客户端根本无法联系到 smtp 服务器。Wireshark 不显示任何 SMTP 交换。
我的 IP 是 192.168.0.105,它位于 NAT 后面。
- 我已经尝试过端口转发,并确保在路由器中为端口转发设置了端口 25。但它不起作用。
- 路由器上的 DDNS。坦率地说,我不知道如何设置它。无论我尝试什么都没有用。
EmailJs 网站连接到 SMTP 服务器单独检查 SMTP 连接。发生连接超时。
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://smtpjs.com/v3/smtp.js"></script> <script> function showMsg() { $( document ).ready(function() { Email.send({ Host : "192.168.0.105", Username : "shwetha@localhost.com", Password : "123456", To : 'shwetha@localhost.com', From : "shwetha@localhost.com", Subject : "This is the subject", Body : "And this is the body" }).then( message => alert(message) ); }) } </script>
期望是确保客户端联系 smtp 服务器并交换 HELO。
解决方案
在 SmtpJS 的 Host 部分中将 IP 更改为 localhost。下一个错误是“服务器不支持安全连接”。这意味着应该在需要弄清楚的 Web 服务器上启用 SSL。
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://smtpjs.com/v3/smtp.js"></script>
<script>
function showMsg() {
$( document ).ready(function() {
Email.send({
Host : "localhost",
Username : "shwetha@localhost.com",
Password : "123456",
To : 'shwetha@localhost.com',
From : "shwetha@localhost.com",
Subject : "This is the subject",
Body : "And this is the body"
}).then(
message => alert(message)
);
})
}
</script>
推荐阅读
- android - 如何将方向设置为intent.putExtra?
- configuration - 是否可以覆盖每个租户的 hbase-site 配置?
- google-apps-script - Google Data Studio 连接器获取报告 URL
- java - 如何在没有 BufferedReader 的情况下从 Java 中的 http get 请求中检索响应
- python - 在多行字符串中打印单行
- javafx - JavaFX圆形径向渐变辐射半圆
- android - 如何通过打开 webview 应用程序而不是主页或主页的链接来加载其他页面
- ios - 单元测试 UICollectionView.indexPath(for: UICollectionViewCell)
- python - pandas read_csv 跳过不需要的描述行和空白行,直到真正的数据部分
- c# - 如何使用 interop.domino.dll c# 程序获取“Internet 域”和“地址名称格式”?