最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

SmtpJs API not working! is there any way to send emails using SMTP server with JavaScript or JQuery - Stack Overflow

programmeradmin1浏览0评论

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.

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.

the fallowing is from smtpjs

<script src="js/smtp.js"></script>
<script>
     Email.send("[email protected]",
                "[email protected]",
                "This is a subject",
                "this is the body",
                "smtp.qwe.io",
                "[email protected]",
                "abcq4#");
</script>

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

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.

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

Thanks in Advance

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.

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.

the fallowing is from smtpjs.com

<script src="js/smtp.js"></script>
<script>
     Email.send("[email protected]",
                "[email protected]",
                "This is a subject",
                "this is the body",
                "smtp.qwe.io",
                "[email protected]",
                "abcq4#");
</script>

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

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.

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

Thanks in Advance

Share Improve this question edited Oct 25, 2017 at 17:26 Manoj Kalluri asked Oct 25, 2017 at 15:32 Manoj KalluriManoj Kalluri 1,4742 gold badges15 silver badges29 bronze badges 3
  • You may want to take a look at EmailJS, which allows sending email using pre-built templates directly from Javascript [disclosure - I'm one of the creators] – Sasha Commented Oct 26, 2017 at 13:06
  • @Sasha, actually I need and SMTP client to send emails. at my enterprise we need to use SMTP server to send email. but when I'm googling most of the answers are we can't use SMTP with JS to send emails. EmailJS don't have this . – Manoj Kalluri Commented Oct 31, 2017 at 14:53
  • EmailJS.com does allow you to connect your own SMTP server and use it for the outgoing emails. I would suggest signing up and taking a look at our dashboard - please feel free to reach out to our support for help, if needed. – Sasha Commented Oct 31, 2017 at 18:09
Add a comment  | 

4 Answers 4

Reset to default 11

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

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

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.

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

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

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

Try using Elastic Email. It works with Smtp.js. I have used it before, and it has, for the most part, worked. Also, make sure you are using the latest versions of both.

Guys this answer is for web user as I implement it in javascript code. I used the smtpjs for it. The code in my js file is this -

Email.send("[email protected]", <--(1) 
[email protected],            <--(2)  
"subject of mail",                 <--(3)   
"This is the body",                <--(4)  
"app.smtp2go.com",                 <--(5) 
"[email protected]",         <--(6)  
"############");                   <--(7) 

First, go to site https://smtpjs.com/ for cdn of smtpjs. Then see,

  1. is sender emailed who will send mail
  2. is the receiver emailed who will receiver sender's mail?
  3. is subject of the mail.
  4. is Body of mail.Same as Gmail body.
  5. is your SMTP server provider which here is app.smtp2go.com.
  6. is account name of SMTP server provider site.
  7. is a password in SMTP server provider site account eg; I have an account name is "[email protected]", and password is something random.

At last here is link for SMTP server provider is https://app.smtp2go.com

I was having similar issues, what help was setting up "Sign in with App Passwords" on my google account.

Here is how to do it https://support.google.com/accounts/answer/185833?hl=en

Sign in with App Passwords

Tip: App Passwords aren’t recommended and are unnecessary in most cases. To help keep your account secure, use "Sign in with Google" to connect apps to your Google Account.

An App Password is a 16-digit passcode that gives a less secure app or device permission to access your Google Account. App Passwords can only be used with accounts that have 2-Step Verification turned on.

When to use App Passwords

Tip: iPhones and iPads with iOS 11 or up don’t require App Passwords. Instead use “Sign in with Google.”

If the app doesn’t offer “Sign in with Google,” you can either:

Use App Passwords

Switch to a more secure app or device Create & use App Passwords If you use 2-Step-Verification and get a "password incorrect" error when you sign in, you can try to use an App Password.

Go to your Google Account. Select Security. Under "Signing in to Google," select App Passwords. You may need to sign in. If you don’t have this option, it might be because: 2-Step Verification is not set up for your account. 2-Step Verification is only set up for security keys. Your account is through work, school, or other organization. You turned on Advanced Protection. At the bottom, choose Select app and choose the app you using and then Select device and choose the device you’re using and then Generate. Follow the instructions to enter the App Password. The App Password is the 16-character code in the yellow bar on your device. Tap Done.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论