Angular Email sending using PHP

Angular Email sending using PHP

Today, We want to share with you Angular Email sending using PHP.
In this post we will show you Email sending with AngularJS and PHP Example, hear for AngularJS Contact Form with Bootstrap and PHPMailer we will give you demo and example for implement.
In this post, we will learn about Email sending with AngularJS and PHP with an example.

READ :  .htaccess Redirect old domain to new domain with URL match

Send email with AngularJS and PHP step by step

Sometimes infinityknow.com may need to send email from blog or our website to the user and client with some attachment Like(resume,invoice.etc..).

It is most used to Validation html fields and sending the form data to the client side to the server is done PHP with AngularJS.
and latest More validation backend side and processing the email is (valid or no) done with PHPMailer on the server and quick response.

In file index.html setup the html form and add all the Angular js directives:

Welcome to the In infinityknow.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.

READ :  Excellent 11 key components of Random Click Photo

Email sending with AngularJS and PHP : File Name : index.html

[php]

AngularJS Email sending with AngularJS and PHP
document.write(”);


[/php]

Main logic and Assign a variable appname to the Angular app in app.js file:

File Name : app.js

[php]

// Angularjs config
var uemailapp = angular.module(’emapp’, []).config(function($sceProvider) {
$sceProvider.enabled(false);
});

uemailapp.controller(‘userMainCtrlemail’, function($scope, $http) {
$scope.userformData = {
‘username’: ”,
‘useremail’: ”,
‘usermessage’: ”
};
$scope.userpostDatadtl = function () {
$http.post(‘http://infinityknow.com/admin/api/v1/form.php’, $scope.userformData)
.success(
function(result_data){
$scope.data_response_display = result_data.replace(/\ /g, ‘  ‘).replace(/\n/g, ‘
‘) // display html web page format response here
})
.error(
function(result_data){
$scope.data_response_display = result_data
})
}
});

[/php]

Second way : Email sending with AngularJS and PHP

[php]

public bool EmailNotification()
{
using (var mail = new MailMessage(emailFrom, “test.test.com”))
{
string body = “Your message : [Ipaddress]/Views/ForgotPassword.html”;
mail.Subject = “Forgot password”; //set subject
mail.Body = body;
mail.IsBodyHtml = false;
var smtp = new SmtpClient();
smtp.Host = “smtp.gmail.com”;
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(emailFrom, emailPwd);
smtp.Port = 587;
smtp.Send(mail);
return true;
}
}

READ :  C# Factorial program Tutorial with Examples

[/php]

[php]
$.ajax({
type: “POST”,
url: “Service.asmx/EmailNotification”,
data: “{}”,
contentType: “application/json; charset=utf-8”,
dataType: “json”,
success: function (data)
{

},
error: function (XHR, errStatus, errorThrown) {
var err = JSON.parse(XHR.responseText);
errorMessage = err.Message;
alert(errorMessage);
}
});
[/php]

Leave a Comment