Node JS. How to send email without third-party mail server - node.js

I need to send (and maybe in the future also receive) email to Node JS without the help of third party servers (such as gmail).
I found node-mailer-direct-transport, but it looks like it is outdated and unsupported.
Is it possible to send email directly using Node JS without a mail server, if not, is it possible to create a mail server locally using Node JS?

You can use maildev. It is a good thing to use the locally easy to build in your environments.
And here is the docker-compose example to run maildev in container

Related

Why does backend development need a seperate server?

I am developing my own website. So far, I've used React for the frontend and Flask for the backend. I've been doing frontend development for a while now but I'm just starting to get into the backend.
From my limited understanding, frameworks like Flask and ExpressJS create their own servers and host data that the frontend can use. It seems to me that that they automatically create websites to host and receive data. In my website, I route the backend to do what I want and use fetch requests with POST and GET from the frontend to communicate.
Although it works, to me, it seems overly complex. Why does the backend need it's own server? It seems unnecessary to create a proxy for the frontend and fetch data. Why can a website not just run custom code in the background, why does it need a service like Flask or ExpressJS to run in the background for it? These backend frameworks run Python or NodeJS in the background, but wouldn't it be much simpler if the website itself could run Python or NodeJS in the background?
I also see that in frameworks like React, you can import things and use modules— like in NodeJS. While importing some modules works, the require keyword is not allowed and normal NodeJS code will not work. Therefore, the backend will not work. Why is this— why can't you just run backend code natively? Instead you have to go through fetch and specify headers to basically translate information from your frontend to your backend.
Forgive my amateur understanding of web development, but the frontend/backend system seems overly complex to me. Thanks in advance.
Why does the backend need it's own server?
Where will the client store data so that when you open the page again the data will still be there? You can use localStorage but this is locked to that particular browser. What if someone logs in on a different device or uses a different browser?
Where will the client get the application from in the first place? Your application needs to be packaged up in a form that can be easily downloaded, and it needs an address to be loaded from. This is all considered "back end" even if you're using a static hosting service like GitHub Pages.
There's a lot of reasons why a back-end exists and needs its own server. Any application with persistent state which is expected to work across different sessions needs at least one of these.

How can I use react with a custom webserver?

I want to use React for a project I am working on, but I also want to use an API.
How can I do it?
I have tried to Google this and ask different people, but I have not got a response yet, so I thought I would ask here. I want to use express and maybe not use create-react-app (as it takes up a lot of storage).
Working on a custom server doesen't preclude the use of an API.
If you want fetch the API from the express server and inject it directly on react frontend you need to enable server side rendering (useful post) and pass the data collected as a props from the server (check this example).
Rather then you can build your react project (using even create-react-app) and build an express server who return the index.html on call.
Personally I prefer the first one solution.

Use nodeJS server with symfony

I have a huge symfony app and I wanted to add some feature that I could only do with a nodeJS server .
So I have a big JSON file which result from my nodeJS run, this file have to go in Symfony.
And symfony have to be able to send some pdf file to the node server (the one which will be transform in JSON by my node server).
Is anyone have some starting idea ?
thansk for help :D
No one is going to be able to provide a full answer with so few details, but generally speaking messaging and remote procedure calls are excellent for interop between parts of a large app.
You could send a message from Symfony (which includes the path of the PDF, or the contents itself), and node will provide the result. You can encode that as JSON, and send it as an answer.
RabbitMq is widely supported, allows both produce-consume or RPC-style use.

Mailing functionality using node.js's nodemailer fails in openshift

I have an issue with nodemailer support in openshift. I created a simple node.js application that sends a mail using nodemailer, following the hello world example given in https://github.com/andris9/Nodemailer
The mail is sent from a gmail id to two other gmail ids. This functionality is invoked while rendering the home page of my application. It worked well when the node.js application was run locally. I created a node js application in openshift and tested the application locally. I worked well. But on deploying the app to open shift, the mailing functionality failed, though the home page was rendered properly.
Is this mailing feature supported in openshift? Or am I missing something, like some extra configuration that is required in openshift for enabling this mailing support?
Thanks.
Hmm, this should work ... can you try changing the port # you are using -- say try 587 with TLS in the
wellknown.js configuration. See if that works.
The other thing to check is that your email provider allows authenticated connections from Amazon AWS EC2 hosts.
HTH

how to integrate node.js into a kohanaPHP application for real time status update notification

I wish to add real time status update notification to a kohanaPHP application with MySQL database i'm developing using node.js, while looking around, i could not find any tutorials about integrating node.js in PHP, i will like to know if its possible and how can it be done and what type of servers should i host the php website on. From what i got its seems node.js does not work on Apache servers. i'll be grateful for help.
Node is it's own server so what you want to do is make a request to the node.js application. You can do this with Curl. One other way is to use Kohana's HMVC feature to make an external request. This example assumes your node.js app returns json.
//Make an external request using post.
$json_request = Request::factory('http://www.example.com/path/to/nodejs')
->method('POST')
->post('my_key', 'value')
->headers('Accept','application/json')
->execute();
//Get the json from the request.
$json_string = $json_request->body();
//Turn the json string into an array.
$json_array = json_decode($json_string);
//Take a look at it with debug.
echo Debug::vars($json_array);
First: You don't run node in any Apache or other web server. It's its own server. So you need to implement data exchange between your Apache/PHP server and node.
You can call your node program via a HTTP request from PHP as soon as something changes and push the new data into your node.
That way you don't need access to MySQL for node, which is not available yet anyway.

Resources