我想收到来自特定地点的邮件

时间:2015-07-01 05:13:47

标签: php mysql sql mailer

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

我已为每个位置分配了一个ID。我想要一封邮件让我知道我是从那个位置收到的。

1 个答案:

答案 0 :(得分:0)

您只需在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)

等等。

修改

带有2个更改的switch语句将如下所示

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;
}