0

我想发送 2 封不同的电子邮件通知申请人他们的奖学金申请。如果用户在组合框中选择了批准,则系统会自动向申请人的电子邮件地址发送电子邮件通知,否则,将发送撤销通知。这是我到目前为止所尝试的:

<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>
<strong>Applicant ID:</strong> <?php echo $id; ?><br />
<strong>Applicant name: </strong> 
<input type="text" name="username" readonly value="<?php echo $lastname. "," . $firstname. " " .substr($middlename, 0,1); ?>"/><br/>
<strong>Username: </strong><input type="text" readonly name="username" value="<?php echo $username; ?>" /> <br />
<strong>Password: </strong><input type="text" readonly name="password" value="<?php echo $password; ?>" /> <br />

<strong>Manage Application: </strong><select name="status">
<?php
    $selection = array(
    0 => "Pending",
    1 => "Approve",
    2 => "Revoke" );

    foreach($selection as $key => $value)
    {
        echo '<option value="' . $key . '"';
        if ($status == $key)
        echo ' selected="selected"';
        echo '>' . $value . '</option>';
        echo ' <br />';
    }
?>
</select>
<br />

<button type="submit" name="submit" value="Submit"><img src="../../images/login.png"   />Update</button>


<?php 

if(isset($_POST['submit']))
{
if($selection == 1){

$to = '.$email.';
//define the subject of the email
$subject = 'Test email'; 
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail."; 
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
if (mail($to, $subject, $message, $headers)) {
echo("<p>Congrats!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}
else if($selection == 2)
{
$to = $email;
//define the subject of the email
$subject = 'Test email'; 
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail."; 
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
if (mail($to, $subject, $message, $headers)) {
echo("<p>Sorry your application is revoked!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
}


} // end of if button pressed

?>

 <a href="../index.php"><button type="button"><img src="../../images/back.png"/>Back</button></a>
</div>
</form> 

但是当我查看电子邮件时它没有发送。这是对的吗?

  $to = $email;

我从一行中得到了 $email['EmailAddress'];

请帮我弄清楚我错过了什么。谢谢。

4

1 回答 1

0

我认为您正在获得发布的价值。就这样吧$to=$_POST["your email address field name"]。希望它能正常工作。尝试一下。

试试下面的颂歌

<?php
$selection = array(
0 => "Pending",
1 => "Approve",
2 => "Revoke" );

$选项="";

foreach($selection as $key => $value)
{
    if ($status == $key)
        $sel='selected="selected"';

    $option.='<option value="'. $key.'" '.$sel.'>'. $value . '</option>';


    echo $option.' <br />';
}

?>

于 2013-02-07T06:05:52.803 回答