Heroku Node.js એપમાં Aspose.Email ક્લાઉડનો ઉપયોગ કરીને ઈમેલ મોકલવું

Heroku node.js એપ્લિકેશન કેવી રીતે સેટ કરવી અને Node.js એપ્લિકેશનમાં ઇમેઇલ મોકલવા માટે Aspose.Email Cloud નો ઉપયોગ કેવી રીતે કરવો તે અંગેનું ટ્યુટોરીયલ.

આ બ્લોગ તમને Heroku પર Node.js એપ કેવી રીતે જમાવવી તે અંગે માર્ગદર્શન આપે છે. અને, લેખ તમને Aspose.Email Cloud અને ઈમેલ મોકલવા માટે તેનો ઉપયોગ કેવી રીતે કરવો તે સમજવામાં મદદ કરે છે. લેખ ધારે છે કે તમારી પાસે પહેલેથી જ મફત Heroku એકાઉન્ટ સેટઅપ છે અને Node.js અને NPM સ્થાનિક રીતે ઇન્સ્ટોલ કરેલું છે. ચાલો, શરુ કરીએ!

Heroku સેટઅપ

પ્રારંભ કરવા માટે તમારે પહેલા Heroku કમાન્ડ લાઇન ઇન્ટરફેસ (CLI) ઇન્સ્ટોલ કરવાની જરૂર છે. Heroku CLI નો ઉપયોગ વિવિધ માપનીયતા કાર્યોનું સંચાલન કરવા અને કરવા માટે થાય છે. તમે એડ-ઓનની જોગવાઈ કરવા, તમારા એપ્લિકેશન લોગ જોવા અને તમારી એપ્લિકેશનને સ્થાનિક રીતે ચલાવવા માટે આનો ઉપયોગ કરી શકો છો. જો તમે macOS નો ઉપયોગ કરી રહ્યાં છો, તો તમે તેને ઇન્સ્ટોલ કરવા માટે Homebrew નો ઉપયોગ કરી શકો છો અથવા સત્તાવાર Heroku ની મુલાકાત લઈ શકો છો.

brew install heroku/brew/heroku

એકવાર ઇન્સ્ટોલેશન થઈ જાય પછી તમે સ્થાનિક રીતે ઉપયોગમાં લેવા માટે Heroku ને પ્રમાણિત કરવા માટે નીચેનો આદેશ ચલાવી શકો છો.

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

આ આદેશ પ્રમાણીકરણ માટે તમારા બ્રાઉઝરને Heroku લૉગિન પેજ પર ખોલે છે. Heroku અને git બંને આદેશો યોગ્ય રીતે કામ કરવા માટે આ જરૂરી છે

Aspose.Email ક્લાઉડ સેટઅપ કરો

Aspose.Email Cloud એ ક્લાઉડમાં ઈમેઈલ આર્કાઈવિંગ માટે ફોલ્ડર સ્ટ્રક્ચર બનાવવા માટે ક્લાઉડ ઈમેઈલ અને સપોર્ટને મોકલવા, પ્રાપ્ત કરવા, જોડવા, ફ્લેગ કરવા અને કન્વર્ટ કરવા માટે ક્લાઉડ SDK છે. આ વાપરવામાં સરળ અને ઝડપી API છે, જેને વધારાના સોફ્ટવેર ઇન્સ્ટોલ કરવાની જરૂર નથી. API ઘણી પ્રોગ્રામિંગ ભાષાઓને સપોર્ટ કરે છે, જેમ કે C#, Java, PHP, Python, Ruby અને Typescript. SDK કેવી રીતે ઇન્સ્ટોલ કરવું તે જાણવા માટે કૃપા કરીને સત્તાવાર માર્ગદર્શિકા માં આપેલી સૂચનાઓને અનુસરો.

Aspose.Email ક્લાઉડનો ઉપયોગ કરીને ઇમેઇલ મોકલવાનું

ધારી રહ્યા છીએ કે તમે પહેલેથી જ Node.js ઇન્સ્ટોલ કર્યું છે, કૃપા કરીને તમારી એપ્લિકેશન માટે ડિરેક્ટરી બનાવો.

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

હવે તમારી main.js ફાઇલમાં નીચેનો કોડ ઉમેરો

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

add following code in your main.js file

//  SDK આયાત કરો
const email = require('@asposecloud/aspose-email-cloud');
const express = require('express')
const app = express()
const port = 5000

// સેટઅપ એપ્લિકેશન ઓળખપત્રો 
const AsposeApp = {
    ClientId: '\*\*\*\*\*',
    ClientSecret: '\*\*\*\*\*',
}

// SDK સેટઅપ કરો
const api = new email.EmailCloud(AsposeApp.ClientId, AsposeApp.ClientSecret)

const credentials = new email.EmailClientAccountPasswordCredentials(
    'my@email.com', '\*\*\*\*\*');
const receiveAccountDto = new email.EmailClientAccount(
    'smtp.email.com', 465, 'SSLAuto', 'SMTP', credentials);

// ઈમેલ મોકલવા માટે ઈમેલ એકાઉન્ટ સેટ કરો
const smtpAccount = 'smtp.account';
const storageName = 'MyEmailStorage';
const accountFolder = 'MyEmailFolder';
const smtpLocation = new email.StorageFileLocation(
    storageName, accountFolder, smtpAccount);


app.get('/', async (req, res) => {
  res.send('Welcome to my email sending app in Node.js')
})

app.get('/setup-account', async (req, res) => {
    await api.client.account.save(new email.ClientAccountSaveRequest(smtpLocation, receiveAccountDto));
    res.send('Account setup successfully');
})

app.get('/send-email', async (req, res) => {
    // ઈમેલ એકાઉન્ટનો ઉપયોગ કરીને ઈમેલ મોકલો
    const emaildto = new email.EmailDto();
    emaildto.from = new email.MailAddress('From address', 'example@gmail.com');
    emaildto.to = [new email.MailAddress('To address', 'to@aspose.com')];
    emaildto.subject = 'Some subject';
    emaildto.body = 'Some body';
    await api.client.message.send(
        new email.ClientMessageSendRequest(
            smtpLocation, new MailMessageDto(emaildto)));
    
    res.send('Email Sent Successfully');

});

app.listen(port, () => {
  console.log(\`Example app listening on port ${port}\`)
})

Heroku પર Node.js એપ્લિકેશનનો ઉપયોગ કરો

એકવાર તમે તમારા બધા ફેરફારો પૂર્ણ કરી લો અને તમારી એપ્લિકેશન પ્રકાશિત કરવા માટે તૈયાર થઈ જાઓ, પછી તમે તમારા ફેરફારોને 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

આ Heroku પર એક ગિટ રિપોઝીટરી બનાવશે અને તમે જે પણ આ રેપો પર દબાણ કરશો તે તમારી Heroku એપ્લિકેશન પર જમાવવામાં આવશે.

$ git push heroku main

હવે તમે હીરોકુ ઓપન કમાન્ડનો ઉપયોગ કરીને તમારી એપ્લિકેશન ખોલી શકો છો.

નિષ્કર્ષ

આ લેખમાં, અમે Heroku પ્લેટફોર્મ અને Heroku પર Node.js એપ્લિકેશનનો ઉપયોગ કરીને ઇમેઇલ મોકલવા વિશે શીખ્યા. અમે Aspose.Email ક્લાઉડનું પણ અન્વેષણ કર્યું, અને ઈમેઈલ ઓનલાઈન મોકલવા માટે SMTP ઈમેલ ક્લાયંટ સેટ કરવા માટે ઉપયોગ કર્યો. Aspose.Email Cloud માત્ર ઇમેઇલ્સ મોકલવા માટે નથી. તેના બદલે, ક્લાઉડમાં ઈમેલ આર્કાઈવિંગ માટે ફોલ્ડર સ્ટ્રક્ચર બનાવવા માટે ક્લાઉડ ઈમેઈલ અને સપોર્ટને મોકલવા, પ્રાપ્ત કરવા, જોડવા, ફ્લેગ કરવા અને કન્વર્ટ કરવા માટે તે ક્લાઉડ SDK છે. આ વાપરવામાં સરળ અને ઝડપી API છે, જેને વધારાના સોફ્ટવેર ઇન્સ્ટોલ કરવાની જરૂર નથી. API ઘણી પ્રોગ્રામિંગ ભાષાઓને સપોર્ટ કરે છે, જેમ કે C#, Java, PHP, Python, Ruby અને Typescript. મને આશા છે કે આ લેખ તમને મદદ કરશે.

અમે ઉત્પાદન દસ્તાવેજીકરણ દ્વારા ક્લાઉડ માટે Aspose.Email ની ક્ષમતાઓનું અન્વેષણ કરવાની ખૂબ ભલામણ કરીએ છીએ. વધુમાં, જો તમને API નો ઉપયોગ કરતી વખતે કોઈ સમસ્યા આવે, તો કૃપા કરીને ફ્રી પ્રોડક્ટ સપોર્ટ ફોરમ દ્વારા સંપર્ક કરો.

અન્વેષણ કરો