SmtpJs API 不工作!有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮

2023-08-02前端开发问题
24

本文介绍了SmtpJs API 不工作!有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个带有 JS 、 Jquery 和 NoSQL DB 的应用程序.我没有任何后端技术,例如 Node 或 C# .我的 Web UI 直接与数据库交互.

I have an application with JS , Jquery and NoSQL DB . I don't have any backend technology such as Node or C# . my web UI directly interacts with DataBase.

现在向数据库提交数据后,我想向用户发送电子邮件通知.我在互联网上搜索,有一些文章说我们在处理 SMTP 服务器时无法使用客户端代码发送电子邮件.

Now after submitting data to DB, I want to send email notifications to users. I searched on internet and there are some articles which say we can't send emails with client side code as we deal with SMTP server.

休闲来自 smtpjs.com

the fallowing is from smtpjs.com

<script src="js/smtp.js"></script>
<script>
     Email.send("vkxyz@abc.com",
                "vk@nyu.edu",
                "This is a subject",
                "this is the body",
                "smtp.qwe.io",
                "vkxyz@abc.com",
                "abcq4#");
</script>

上面的代码段不起作用.尝试了互联网上可用的其他一些片段,但没有任何效果.

the above snippet is not working. tried some other snippets available on internet but nothing works.

顺便说一下,我的 SMTP 服务器有防火墙,并且只接受来自本地网络.上面的代码我没有得到任何连接错误日志.

By the way my SMTP server has firewall and accepts from local network only. I din't get any connection error log with above code.

那么是否可以使用 JavaScript Jquery 发送电子邮件,如果可以,请提出最佳做法

so is it possible to send email with JavaScript Jquery , if so please kindly suggest the best practice

提前致谢

推荐答案

无法使用带有 JS 或 Jquery 的 SMTP 服务器发送电子邮件.

It is not possible to send emails using SMTP servers with JS or Jquery.

没有办法直接从我们的浏览器访问 SMTP 服务器.

There is no way to hit SMTP server directly from our browsers.

EmailJS 或 SMTPJs 为我们提供 API,但最终我们使用他们的服务器来访问 SMTP.实际上,我们正在向他们的服务器发送数据,该服务器进一步向 SMTP 服务器发送数据.

EmailJS or SMTPJs gives us API but eventually we are using their servers to hit the SMTP. actually we are sending data to their server which further sends data to SMTP servers.

所以我们必须需要一个服务器来发送到 SMTP.我们可以使用 NodeJs、C#、Python 或 Java 来做到这一点.

So we must need a server to send to SMTP. and we can use NodeJs,C#,Python or Java to do this.

就我而言,我什至尝试过 EmailJs ,但我的 SMTP 服务器阻止了 EmailJs 服务器 IP 地址.

In my case I even tried EmailJs , but my SMTP server blocks EmailJs server IP address.

如果您使用的是企业级 SMTP 服务器,则绝对不能通过浏览器 JS &查询.您必须在后端使用服务器并在 NodeJS 等中编写一些代码...

If you are using enterpise SMTP server , in no way you can email through browser JS & Jquery. you must use a server in backend and write some code in NodeJS etc...

谢谢 &如果我错了,请纠正我

Thanks & correct me If I am wrong

这篇关于SmtpJs API 不工作!有没有办法使用带有 JavaScript 或 JQuery 的 SMTP 服务器发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

ajax请求获取json数据并处理的实例代码
ajax请求获取json数据并处理的实例代码 $.ajax({ type: 'GET', url: 'https://localhost:44369/UserInfo/EditUserJson',//请求数据 data: json,//传递数据 //dataType:'json/text',//预计服务器返回的类型 timeout: 3000,//请求超时的时间 //回调函数传参 suc...
2024-11-22 前端开发问题
215

js删除数组中指定元素的5种方法
在JavaScript中,我们有多种方法可以删除数组中的指定元素。以下给出了5种常见的方法并提供了相应的代码示例: 1.使用splice()方法: let array = [0, 1, 2, 3, 4, 5];let index = array.indexOf(2);if (index -1) { array.splice(index, 1);}// array = [0,...
2024-11-22 前端开发问题
182

layui 实现实时刷新一个外部的div
主页面上显示了一个合计,在删除和增加的时候需要更改这个总套数的值: //html代码div class="layui-inline layui-show-xs-block" style="margin-left: 10px" id="sumDiv"spanSOP合计:/spanspan${totalNum}/spanspan套/span/div 于是在我们删除这个条数据后,...
2024-11-14 前端开发问题
156

layui 单选框、复选框、下拉菜单不显示问题如何解决?
1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
2024-11-09 前端开发问题
313

layui要如何改变时间日历布局大小?
问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
2024-10-24 前端开发问题
271

layui中表单会自动刷新的问题
layui中表单会自动刷新的问题,因为用到layui的表单,遇到了刷新的问题所以记录一下: script layui.use(['jquery','form','layer'], function(){ var $ = layui.jquery, layer=layui.layer, form = layui.form; form.on('submit(tijiao)', function(data){ a...
2024-10-23 前端开发问题
262