php - 我想接收来自特定位置的邮件

标签 php mysql sql mailer

这是我的代码 http://codepad.org/NHykpcrq

我为每个位置指定了一个单独的 ID。我想要一封邮件让我知道我从该位置收到了邮件。

最佳答案

您可以在 if 语句中分配一个值(您可能希望将其更改为 switch 语句)

if ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=1') {
    $to = 'tanmay.kamath1992@gmail.com';
    $location = 'Some Name for this thing';
} elseif ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=2') {
    $to = 'tanmay.kamath1992@gmail.com';
    $location = 'Some Name for this thing 2';
} elseif ($host == 'locahost/dribblefootball/calendar_new/calendar.php?id=3') {
    $to = 'tanmay.kamath1992@gmail.com';
    $location = 'Some Name for this thing 3';
} else { //other options
    $to = 'others@mysite.com';
    $location = 'Some Name for this thing else';
}
$formcontent .= '\n Sent from '.$location;

您的 localhost 内容可能存在拼写错误:),另一个 idé(使其可移植)是将您要查找的内容更改为如下所示:

($_GET['id'] === 1)

等等。

编辑

一个switch包含 2 个更改的语句如下所示

switch ($_GET['id']) {
    case 1:
        $to = 'tanmay.kamath1992@gmail.com';
        $location = 'Some Name for this thing';
        break;
    case 2:
        $to = 'tanmay.kamath1992@gmail.com';
        $location = 'Some Name for this thing 2';
        break;
    case 3:
        $to = 'tanmay.kamath1992@gmail.com';
        $location = 'Some Name for this thing 3';
        break;
    default:
        $to = 'others@mysite.com';
        $location = 'Some Name for this thing else';
        break;
}

关于php - 我想接收来自特定位置的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31152999/

相关文章:

sql - 将 JOIN 查询重写为子查询/更快的变体

php - Laravel 项目 ERR_EMPTY_RESPONSE

php - 从具有相同名称但不同表的两列中检索数据

php - MySQL/PHP更新查询错误

mysql - 无法插入 Amazon RDS 数据库

php - 如何将 SCORM 2004 session_time 格式转换为 SQL 中可用的日期时间格式

php - 有没有一种(简单的)方法可以在纯 PHP 中分离模型,这样做的好方法是什么?

sql - Mysql选择分组

mysql - 在 MySQL 中使用两次子查询的结果

sql - 一行基本 SQL Pivot?