Hello everyone:
I am wondering if there is a way to use different suject line for different recipients.
I am using PHP mail function to send out email which confirm account registration. Email
will be send to students who registered an account, the lab assistant will also get an email
contain the same account registration information.
I want use different subject line for student and lab assistant.
Would it be possible to achieve this by using one mail function? Please give me some advises.
If you know some online resource discuss this topic please let me know. Thanks for your help!
PHP code I used for mail function.
[code=php]$mailto = “$email”;
$subject = “Computer Lab Account Registration Confirmation Email”;
$message = “”;
$under_gradAccount =””;
$gradAccounts = “”;
$gradAccount1 = “”;
/*
note: you need to include MIME type and content-type in order to
include message body fomatted with html tags.
Add multiple recipents in header portion
*/
$header .= “MIME-Version: 1.0n”;
$header .= “Content-type: text/html; charset=iso-8859-1n”;
$header .= “From: $fname $lname <$email>n”;
//$header.=”Cc:[email protected]”;
$header.=”Bcc:[email protected]”;
print (“First name: $fname. <br />”);
print (“Last name: $lname. <br />”);
print (“Gender: $gender. <br />”);
print(“Age: $age. <br />”);
print (“Department: $departments. <br />”);
print (“Email: $email. <br />”);
print (“Phone number: $phone_num. <br />”);
if($class_standing == “undergraduate”)
{
print “You are an $class_standing student.<br /> You applied for the following account(s):<br />”;
if(is_array($_POST[‘undergrad_account’]))
{
foreach($_POST[‘undergrad_account’] as $undergradAccount)
{
print (“$undergradAccount<br />”);
}
}
}
if($class_standing == “graduate”)
{
print (“You are a $class_standing student.<br /> You applied for the following account(s):<br />”);
if(is_array($_POST[‘undergrad_account’]))
{
foreach($_POST[‘undergrad_account’] as $undergradAccount)
{
print (“$undergradAccount<br />”);
}
}
if(is_array($_POST[‘grad_account’]))
{
foreach($_POST[‘grad_account’] as $gradAccount)
{
print (“$gradAccount<br />”);
}
}
}
$message =”<html><body>”;
$message .=”<h4>Please verify your account information.<br />If you have any questions, please contact <a href=”mailto:[email protected]”>Computer Lab Account Service</a>.</h4>”;
$message .=”<hr style=”color: orange; width: 800px;” />”;
$message .= “First name: $fname. <br />”;
$message .= “Last name: $lname. <br />”;
$message .= “Gender: $gender. <br />”;
$message .= “Age: $age. <br />”;
$message .= “Department: $departments. <br />”;
$message .= “Email: $email. <br />”;
$message .= “Phone: $phone_num. <br />”;
$message .= “You are a(n): $class_standing student. <br />”;
$message .= “You applied for the following accounts: <br />”;
//use implode function to convert array to string, so account option
//can be displayed in the email
if($class_standing == “undergraduate”)
{
if(is_array($_POST[‘undergrad_account’]))
{
$under_gradAccount .= implode(‘, ‘, $_POST[‘undergrad_account’]); //convert undergraduate account option from an array into a string
$message .= “–“. $under_gradAccount.”<br />”;
}
}
/*
convert graduate account into a string format
*/
if($class_standing == “graduate”)
{
//test to see if undergraduate checkbox group being checked
if(is_array($_POST[‘undergrad_account’]))
{
$gradAccount1 .= implode(‘, ‘, $_POST[‘undergrad_account’]);
}
else
$gradAccount1 = “”;
if(is_array($_POST[‘grad_account’]))
{
$gradAccounts .= implode(‘, ‘, $_POST[‘grad_account’]);
}
$message .= “–“.$gradAccount1 . ‘<br />’;
$message .= “–“.$gradAccounts.'<br />’;
}
if(empty($comments))
{
print “You did not enter any comments.”;
}
if(!empty($comments))
{
$message .= “Your comments on our account services are shown below:<br />”;
$message .= “‘ $comments'<br />”;
}
$message .= “The services you requested will be available once we approve your application.”;
$message .=”<hr style=”color: orange; width: 800px;” />”;
$message .= “<br /><br />Computer Lab Account Services<br />San Jose State University”;
$message .=”</body></html>”;
?>
webdev077
8-9-07