Subject: php mail function - use different subject based on the recipients
am 11.08.2007 09:01:25 von apasj06
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.
$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.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1\n";
$header .= "From: $fname $lname <$email>\n";
$header.="Bcc:santa98bn@yahoo.com\n";
print ("First name: $fname.
");
print ("Last name: $lname.
");
print ("Gender: $gender.
");
print("Age: $age.
");
print ("Department: $departments.
");
print ("Email: $email.
");
print ("Phone number: $phone_num.
");
if($class_standing == "undergraduate")
{
print "You are an $class_standing student.
You applied for
the following
account(s):
";
if(is_array($_POST['undergrad_account']))
{
foreach($_POST['undergrad_account'] as $undergradAccount)
{
print ("$undergradAccount
");
}
}
}
if($class_standing == "graduate")
{
print ("You are a $class_standing student.
You applied for
the following
account(s):
");
if(is_array($_POST['undergrad_account']))
{
foreach($_POST['undergrad_account'] as $undergradAccount)
{
print ("$undergradAccount
");
}
}
if(is_array($_POST['grad_account']))
{
foreach($_POST['grad_account'] as $gradAccount)
{
print ("$gradAccount
");
}
}
}
$message ="
";
$message .="Please verify your account information.
If you
have any
questions, please contact
\">Computer Lab Account
Service.
";
$message .="
";
$message .= "First name: $fname.
";
$message .= "Last name: $lname.
";
$message .= "Gender: $gender.
";
$message .= "Age: $age.
";
$message .= "Department: $departments.
";
$message .= "Email: $email.
";
$message .= "Phone: $phone_num.
";
$message .= "You are a(n): $class_standing student.
";
$message .= "You applied for the following accounts:
";
//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."
";
}
}
/*
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 . '
';
$message .= "--".$gradAccounts.'
';
}
if(empty($comments))
{
print "You did not enter any comments.";
}
if(!empty($comments))
{
$message .= "Your comments on our account services are shown
below:
";
$message .= "' $comments'
";
}
$message .= "The services you requested will be available once we
approve your
application.";
$message .="
";
$message .= "
Computer Lab Account Services
San Jose
State
University";
$message .="";
?>
Re: Subject: php mail function - use different subject based on the recipients
am 11.08.2007 10:32:28 von kevin bailey
apasj06 wrote:
> 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.
>
> $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.0\n";
> $header .= "Content-type: text/html; charset=iso-8859-1\n";
> $header .= "From: $fname $lname <$email>\n";
> $header.="Bcc:santa98bn@yahoo.com\n";
>
>
>
> print ("First name: $fname.
");
> print ("Last name: $lname.
");
>
> print ("Gender: $gender.
");
>
> print("Age: $age.
");
>
> print ("Department: $departments.
");
>
> print ("Email: $email.
");
>
> print ("Phone number: $phone_num.
");
>
> if($class_standing == "undergraduate")
> {
> print "You are an $class_standing student.
You applied for
> the following
>
> account(s):
";
>
> if(is_array($_POST['undergrad_account']))
> {
> foreach($_POST['undergrad_account'] as $undergradAccount)
> {
> print ("$undergradAccount
");
> }
> }
>
> }
>
>
>
> if($class_standing == "graduate")
> {
> print ("You are a $class_standing student.
You applied for
> the following
>
> account(s):
");
>
> if(is_array($_POST['undergrad_account']))
> {
> foreach($_POST['undergrad_account'] as $undergradAccount)
> {
> print ("$undergradAccount
");
> }
> }
>
> if(is_array($_POST['grad_account']))
> {
> foreach($_POST['grad_account'] as $gradAccount)
> {
> print ("$gradAccount
");
> }
> }
> }
>
>
>
>
> $message ="
";
> $message .="Please verify your account information.
If you
> have any
>
> questions, please contact
> \">Computer Lab Account
>
> Service.
";
> $message .="
";
> $message .= "First name: $fname.
";
> $message .= "Last name: $lname.
";
> $message .= "Gender: $gender.
";
> $message .= "Age: $age.
";
> $message .= "Department: $departments.
";
> $message .= "Email: $email.
";
> $message .= "Phone: $phone_num.
";
>
> $message .= "You are a(n): $class_standing student.
";
> $message .= "You applied for the following accounts:
";
> //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."
";
> }
>
> }
>
> /*
> 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 . '
';
> $message .= "--".$gradAccounts.'
';
> }
>
> if(empty($comments))
> {
> print "You did not enter any comments.";
> }
>
> if(!empty($comments))
> {
> $message .= "Your comments on our account services are shown
> below:
";
> $message .= "' $comments'
";
> }
>
> $message .= "The services you requested will be available once we
> approve your
>
> application.";
> $message .="
";
>
> $message .= "
Computer Lab Account Services
San Jose
> State
>
> University";
>
> $message .="";
>
> ?>
Maybe look into the PEAR mail_queue library - you can then manipulate lines
in the DB before sending out?
Kevin
Re: Subject: php mail function - use different subject based on therecipients
am 11.08.2007 16:02:18 von Jerry Stuckle
apasj06 wrote:
> 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.
Well, I don't see where you're actually calling the PHP mail function,
but from you code I guess $subject is the subject of your message.
If you're sending the message to the student and CC'ing, BCC'ing, etc.,
the lab assistant, then no - both will get the same message.
Now if you're sending two messages, you can do it easily. You just need
to change $subject before you send the message to the lab assistant.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================