从另一个 PHP 文件发送电子邮件(使用 GET 参数)


send email (with GET params) from another php file

>我在文件中定义了一个电子邮件函数:wel1.php

我需要在另一个 php 文件的中间调用它,我正在尝试用:

 include 'bienvenido/wel1.php?to="'.user.'"&pass="'.pass.'"';

如果我只是在浏览器的地址栏中输入以下内容,我就可以正确发送电子邮件:

 bienvenido/wel1.php?to=some_email@gmail.com&pass=password

我错过了什么?

问候。

我认为你不能像这样传递GET参数。
由于包含的文件使用相同的变量范围,您只需在包含之前设置 $_GET 变量即可。喜欢这个:

$_GET['to'] = $user;
$_GET['pass'] = $pass;
include 'bienvenido/wel1.php";

你会得到你想要的

变量

的美元符号:

include 'bienvenido/wel1.php?to="'.$user.'"&pass="'.$pass.'"';

你忘记了变量名前面的$:$user和$pass

所以试试:include 'bienvenido/wel1.php?to="'.$user.'"&pass="'.$pass.'"';