dourun2990 2018-08-27 21:28 采纳率: 100%
浏览 31
已采纳

我可以在角应用程序中放置PHP文件吗?

I've got my angular app on my web server and I need the app to send an email!

Most simple way I can think is to just send data from Angular to a PHP file which can just execute PHP Mail.

Trouble is, I've made a directory within the app called /php, and inserted a .php file. When I aim at the .php file, it takes me to my app but with no data or anything. I really just want it to execute the .php file.

Now I do understand, the app is running in express server which will not run PHP, so is there a way around this?

Thanks (I'm running Angular 6)

  • 写回答

1条回答 默认 最新

  • doujiao8649 2018-08-27 21:54
    关注

    I have a single mail sending script that works based off information sent to it via $_POST, so when I need to send mail from anything I just generate a post to my super script with the correct form fields/values in it. I can post from Java, Angular/JS stuff, PHP, curl on the command line, whatever.

    For your situation, I would use a similar approach. Add in some authentication to be sure it is your angular app that is sending the post, and it should be relatively quick and easy.

    BUT... that PHP script must run on a webserver wtih properly configured mail system for the mail() call to work

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?