Email Sending using Aspose.Email Cloud in Heroku Node.js App

A tutorial on how to setup a heroku node.js app, and how to use Aspose.Email Cloud for email sending in Node.js application.

This blog guides you on how to deploy a Node.js app on Heroku. And, the article helps you understand Aspose.Email Cloud, and how to use it for email sending. The article assumes that you already have a free Heroku Account setup and Node.js and NPM installed locally. Let’s get started!

Setup Heroku

To get started you first need to install the Heroku Command Line Interface (CLI). Heroku CLI is used to manage and perform various scalability tasks. You can use this to provision add-ons, view your application logs, and run your application locally. If you are using macOS, you can use Homebrew to install it or can visit the official Heroku.

brew install heroku/brew/heroku

Once the installation is done you can run the following command to authenticate Heroku to be used locally.

heroku login
heroku: Press any key to open up the browser to login or q to exit
 ›   Warning: If browser does not open, visit
 ›   https://cli-auth.heroku.com/auth/browser/\*\*\*
heroku: Waiting for login...
Logging in... done
Logged in as me@example.com

This command opens your browser to the Heroku login page for authentication. This is required for both Heroku and git commands to work properly

Setup Aspose.Email Cloud

Aspose.Email Cloud is a Cloud SDK to send, receive, append, flag, and convert cloud emails & support to create a folder structure for email archiving in the cloud. This is easy to use and fast API, that doesn’t need to install the additional software. The API supports many programming languages, such as C#, Java, PHP, Python, Ruby & Typescript. To know how to install the SDK please follow the instructions in official guide.

Email Sending using Aspose.Email Cloud

Assuming you’ve already installed Node.js, please create a directory for your application.

$ mkdir my-email-sending-app
$ cd my-email-sending-app
$ npm init
$ npm install express --save
$ npm install @asposecloud/aspose-email-cloud

Now add the following code in your main.js file

Deploy Node.js App to Heroku

Once you are done with all your changes and ready to publish your app, you can use the following commands to push your changes to Heroku.

$ heroku create
Creating sharp-rain-871... done, stack is heroku-18
http://sharp-rain-871.herokuapp.com/ | https://git.heroku.com/sharp-rain-871.git
Git remote heroku added

this will create a git repository on Heroku and anything you push to this repo will get deployed to your Heroku application.

$ git push heroku main

Now you can open your application using the heroku open command.

Conclusion

In this article, we learned about the Heroku platform and sending email using Node.js application on Heroku. We also explored the Aspose.Email Cloud, and used to set up an SMTP email client to send email online. Aspose.Email Cloud isn’t just for sending emails. Instead, it’s a Cloud SDK to send, receive, append, flag, and convert cloud emails & support to create a folder structure for email archiving in the cloud. This is easy to use and fast API, that doesn’t need to install the additional software. The API supports many programming languages, such as C#, Java, PHP, Python, Ruby & Typescript. I hope this article helped you.

We highly recommend exploring the capabilities of Aspose.Email for Cloud via Product Documentation. Furthermore, if you encounter any issue while using the API, please feel free to contact via Free product support forum.

Explore