1

I am programming a mobile application in Ionic which uses angular/typescript. I am looking for a front end solution for sending email dynamically in the background to a pre-determined email address. I have tried to use emailjs but it is only a front-end solution if it is used with javascript which is not compatible with Ionic. The other mail client that I have found is for typescript and it is called "nodemailer". The tutorial I found for nodemailer is at this link; https://subscription.packtpub.com/book/application_development/9781786468710/12/ch12lvl1sec71/sending-mail

I followed the installation instructions for installing nodemailer but I got an error. The installation parts that installed successfully were;

  • npm install --save nodemailer
  • npm install @types/node --save
  • npm install @types/nodemailer --save
  • npm install @types/nodemailer-direct-transport --save
  • npm install @types/nodemailer-smtp-transport --save

The installation that had an error was;

npm install @types/nodemailer-bluebird --save

The error for the above command was;

npm ERR! code E404 
npm ERR! 404 Not Found: @types/nodemailer-bluebird@latest
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nicholas1\AppData\Roaming\npm-cache\ _logs\2019-09-09T17_59_48_776Z-debug.log
Any help with this error will be greatly appreciated because I could not find any helpful information online for the 404 error above. If you need any additional information please ask me.

Minimal Reproducible Example;

  • install node.js and npm; https://www.npmjs.com/get-npm
  • install ionic and cordova cli run: C:> npm install -g cordova ionic -> to see your ionic version run: ionic -v
  • change to your workspace directory then install project and template with command; C:\Desktop> ionic start myApp blank
  • Test app in web browser, it should work at this point and you will see text that says "The world is your oyster."; --> C:\Desktop\myApp> ionic serve
  • Follow install instructions at link; https://subscription.packtpub.com/book/application_development/9781786468710/12/ch12lvl1sec71/sending-mail

  • Next run the following commands, these are also the installation parts that you should be able to install successfully;

    • C:\Desktop\myApp> npm install --save nodemailer
    • C:\Desktop\myApp> npm install @types/node --save
    • C:\Desktop\myApp> npm install @types/nodemailer --save
    • C:\Desktop\myApp> npm install @types/nodemailer-direct-transport --save
    • C:\Desktop\myApp> npm install @types/nodemailer-smtp-transport --save

Next install instruction, this should have an error;

npm install @types/nodemailer-bluebird --save

  • The error for the above command was;

npm ERR! code E404 npm ERR! 404 Not Found: @types/nodemailer-bluebird@latest npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\User1\AppData\Roaming\npm-cache\ _logs\2019-09- 09T17_59_48_776Z-debug.log

Programminghobby
  • 105
  • 1
  • 6
  • 16

2 Answers2

2

I had the same issue issue installing @types/nodemailer-bluebird However @types/bluebird instead which worked for me.

here is the link to the npm package:

https://www.npmjs.com/package/@types/bluebird

gutscdav000
  • 359
  • 1
  • 3
  • 14
  • Were you able to send email with the nodemailer library on the client side? I would love to hear your experience in detail! – Programminghobby Apr 22 '20 at 02:58
  • Yes I was able to send the email; However, I was writing server side node. Like others have suggested it may not be the best idea or a feasible solution to do it from the client side so I can't provide any expertise there. – gutscdav000 Dec 24 '20 at 21:34
0

You shouldn't be sending emails from client side. You can create a webAPI endpoint which sends emails from server-side and then hit that endpoint from client-side.

Nodemailer is nodejs only solution and is not expected to work in web browsers. Explanation here: https://stackoverflow.com/a/37636122/5171009

Prabh
  • 989
  • 5
  • 10
  • My code is for ionic which is hybrid language for mobile applications, why can't sending email be accomplished on client side because I was able to achieve autonomous email in Native Android. Here is an example of autonomous email in Native Android; https://stackoverflow.com/a/4668924/3576562 . The only time ionic is in a web browser is when I am testing on the PC before testing on the mobile device. – Programminghobby Nov 15 '19 at 01:26
  • It is worth considering that people using server side node could make use of this information as well. – gutscdav000 Apr 20 '20 at 16:06