I have created single page application using angular which contains contact form. for contact form i have used php mail function. I'm keeping that php file inside assets folder of angular project.
I am using angular HTTPCLIENT module to call that contact php file using below code in component:
this.http.sendEmail(user).subscribe(
data => {
let res:any = data;
// debugger;
console.log(`${user.name} is successfully booked appointment.`);
this.elementRef.nativeElement.querySelector('.contact-form').innerHTML = "<div class='inner-content'><p class='success-msg'>Thanks for contacting us. We will contact you ASAP!</p>";
},
err => {
console.log(err);
this.loading = false;
this.buttonText = "Submit";
},() => {
this.loading = false;
this.buttonText = "Submit";
}
);
}
Service Code:
sendEmail(data: any) {
return this.http.post(`../assets/inc/email.php`, data);
}
I am trying to post the contact form. it's not taking the php file. How to solve this issue please help me. Actually i am trying first time Anguar with Php. So please any help me to achieve this.