<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Send Emails without a server-side code with Angular]]></title><description><![CDATA[<p dir="auto"><img src="https://miro.medium.com/max/800/0*_vui1Vw7BYbbvnrE.png" alt="alt text" class=" img-responsive img-markdown" /><br />
Without any server-side code hosted on a server, you can send emails through your Angular application with smtpJS, a client-side Javascript library.</p>
<p dir="auto">First you need to download this library and include it into the necessary component of the Angular Application.<br />
<a href="https://www.smtpjs.com/v3/smtp.js" target="_blank" rel="noopener noreferrer nofollow ugc">Click here</a> to download the library file.<br />
(If any error in download, go to <a href="https://www.smtpjs.com/" target="_blank" rel="noopener noreferrer nofollow ugc">smtpJS.com</a> , where you can directly download or get the CDN link)</p>
<p dir="auto">Next , put this downloaded js file into the <strong>assets</strong> folder found in <strong>src</strong> directory of the project.</p>
<p dir="auto">Next we have to get the help of an email service provider to send the email. I here use <a href="https://elasticemail.com/account#/create-account" target="_blank" rel="noopener noreferrer nofollow ugc">Elastic Email</a> site for this. First go to the Elastic Email site to create an account. Just complete the sign up process, it’s that simple.</p>
<p dir="auto">After logging into the site, go to Start — → Connect To SMTP API .</p>
<p dir="auto"><img src="https://miro.medium.com/max/800/0*uWOgRJbxjMzXFON0.PNG" alt="alt text" class=" img-responsive img-markdown" /></p>
<p dir="auto">Next, you can see a button to create new credentials. Create a new credentials following the simple steps. The system will generate a password for you. <strong>Copy that password and save it somewhere before you close that popup model.</strong></p>
<p dir="auto">Finally you’ll see something like this.</p>
<p dir="auto"><img src="https://miro.medium.com/max/800/0*r2kkKEls6v3SkjEz.PNG" alt="alt text" class=" img-responsive img-markdown" /></p>
<p dir="auto">Here, your user name and password (You saved it earlier) can be seen .These details are used to access this.</p>
<p dir="auto"><strong>Coding part</strong></p>
<p dir="auto">Go to your angular project’s relevant component from which an email must be sent.</p>
<ol>
<li>
<p dir="auto">Import the smtp.js file from assets folder to the component by typing<br />
<em><strong>import ‘./../../../assets/smtp.js’;                  &lt;! — path might change — &gt;<br />
declare let Email : any;</strong></em></p>
</li>
<li>
<p dir="auto">Write the code to send the email with the user-inputs within onSubmit() method as below,</p>
</li>
</ol>
<pre><code>import { Component, OnInit } from '@angular/core';
import { ProfileService } from '../profile.service';
import { Model } from './contact-form';
import { NgForm } from '@angular/forms';
import  './../../../assets/js/smtp.js '; &lt;! — file path may change →
declare let Email: any;

@Component({ selector: ‘app-contact’,
 templateUrl: ‘./contact.component.html’,
 styleUrls: [‘./contact.component.scss’]})

export class ContactComponent implements OnInit {

model: Model = new Model();

constructor( private profile: ProfileService) { }

ngOnInit() {
}

onSubmit(f: NgForm) {

Email.send({
              Host : ‘smtp.elasticemail.com’,
             Username : ‘udith.indrakantha@gmail.com’, 
             Password : ‘**************************’,          //Enter your password here
             To : ‘udith.indrakantha@gmail.com’,
             From : `udith.indrakantha@gmail.com`,
             Subject : this.model.subject,
            Body : `
                   &lt;i&gt;This is sent as a feedback from my resume page.&lt;/i&gt; &lt;br/&gt;
                   &lt;b&gt;Name: 
                  &lt;/b&gt;${this.model.name} &lt;br /&gt;
                   &lt;b&gt;Email: &lt;/b&gt;${this.model.email}&lt;br /&gt;
                  &lt;b&gt;Subject: 
                  &lt;/b&gt;${this.model.subject}&lt;br /&gt;
                  &lt;b&gt;Message:&lt;/b&gt; &lt;br /&gt; 
                  ${this.model.message} &lt;br&gt; 
                  &lt;br&gt; &lt;b&gt;~End of Message.~&lt;/b&gt; `
}).then( 
             message =&gt; {alert(message); f.resetForm(); } 
             );
    }
}
</code></pre>
<p dir="auto">Here , within <em><strong>Email.send(….);</strong></em> method, you can give the elastic mail registered email as the username ,<br />
and earlier saved password for the password field.<br />
<em><strong>From</strong></em>: email should be equal to the elastic mail’s registered email and you can set the receiver’s email under <strong>To</strong> field.</p>
<p dir="auto">Other fields can be taken from your form created .</p>
<p dir="auto">That’s it.</p>
<p dir="auto">Original Post:  <a href="https://medium.com/@udith.indrakantha/send-emails-without-a-server-side-code-with-angular-e227c3e62dbd" target="_blank" rel="noopener noreferrer nofollow ugc">https://medium.com/@udith.indrakantha/send-emails-without-a-server-side-code-with-angular-e227c3e62dbd</a></p>
]]></description><link>https://lankadevelopers.lk/topic/460/send-emails-without-a-server-side-code-with-angular</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 03:53:30 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/460.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 22 Dec 2019 16:16:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Thu, 26 Dec 2019 20:27:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/216">@Udith-Indrakantha</a></p>
<p dir="auto">awesome bro , thank you</p>
]]></description><link>https://lankadevelopers.lk/post/2673</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2673</guid><dc:creator><![CDATA[root]]></dc:creator><pubDate>Thu, 26 Dec 2019 20:27:55 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Thu, 26 Dec 2019 15:06:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://lankadevelopers.lk/uid/27">@root</a> Yes bro. we can use it for Ionic also because SMTP js is a javascript code. You just need to add the file and import it to the .ts file if the component.  The way to import a js file is simply the same described in this post.</p>
]]></description><link>https://lankadevelopers.lk/post/2670</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2670</guid><dc:creator><![CDATA[Udith Indrakantha]]></dc:creator><pubDate>Thu, 26 Dec 2019 15:06:08 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Thu, 26 Dec 2019 10:40:41 GMT]]></title><description><![CDATA[<p dir="auto">Thanks bro very helpful:relaxed:</p>
]]></description><link>https://lankadevelopers.lk/post/2668</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2668</guid><dc:creator><![CDATA[Pasan Induwara]]></dc:creator><pubDate>Thu, 26 Dec 2019 10:40:41 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Tue, 24 Dec 2019 08:39:09 GMT]]></title><description><![CDATA[<p dir="auto">Thank you bro</p>
]]></description><link>https://lankadevelopers.lk/post/2660</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2660</guid><dc:creator><![CDATA[imadusanka]]></dc:creator><pubDate>Tue, 24 Dec 2019 08:39:09 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Mon, 23 Dec 2019 05:32:41 GMT]]></title><description><![CDATA[<p dir="auto">good article bro, thanks</p>
]]></description><link>https://lankadevelopers.lk/post/2649</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2649</guid><dc:creator><![CDATA[dev_lak]]></dc:creator><pubDate>Mon, 23 Dec 2019 05:32:41 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Mon, 23 Dec 2019 04:11:31 GMT]]></title><description><![CDATA[<p dir="auto">wow good article</p>
]]></description><link>https://lankadevelopers.lk/post/2647</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2647</guid><dc:creator><![CDATA[Nubelle]]></dc:creator><pubDate>Mon, 23 Dec 2019 04:11:31 GMT</pubDate></item><item><title><![CDATA[Reply to Send Emails without a server-side code with Angular on Sun, 22 Dec 2019 22:59:47 GMT]]></title><description><![CDATA[<p dir="auto">Good article bro. Can we use SMTP js for ionic ?</p>
]]></description><link>https://lankadevelopers.lk/post/2646</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2646</guid><dc:creator><![CDATA[root]]></dc:creator><pubDate>Sun, 22 Dec 2019 22:59:47 GMT</pubDate></item></channel></rss>