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

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

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行