Jump to content

PHP Email Different People


lesham

Recommended Posts

I have a contact page that needs the following done:

It needs to send an email to someone based on decision 1 (drop down box 1) + decision 2 (drop down box 2).

I have posted the code for the html form.

I have also posted the code for my contact.php file.  Im not sure if it works or not, but i would appriciate it if someone took a look at it and see if they can improve it or not.

Remember im trying to send an email out based on two decisions, not just 1.

Thanks so much  :)

[table[color=green]]<?
/* The skeleton */

$who = $_POST['who'];
$typeOfInfo = $_POST['typeOfInfo'];

$nameOfWho = array(
1 => "Prospective insured",
    "Prospective agent",
    "Insured",
    "Agent",
    "Unknown Person"
);

$nameOfInfo = array(
1 => "Request Claim Information",
    "Request information about my policy",
    "Request information about obtaining my policy",
    "Request my password",
    "Comment on your website",
    "Contact you on an unlisted topic"
);

$list = array(
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]"
);

$typeOfInfoPeople = array(
1=> array("$list[0], $list[1]", NULL, NULL, NULL, NULL),
    array($list[1], $list[2], NULL, NULL, NULL, $list[5]),
    array(NULL, $list[2], NULL, $list[5], NULL, $list[5]),
    array(NULL, NULL, NULL, NULL, NULL, $list[5]),
    array(NULL, NULL, $list[3], NULL, NULL, $list[5]),
    array("$list[0], $list[1]",
              "$list[0], $list[2]",
                    "$list[0], $list[3]",
                          "$list[0], $list[4]",
                                  "$list[0], $list[5]",
                                        "$list[0], $list[1], $list[2], $list[3], $list[4], $list[5]"
));

$post = "$name, a ". $nameOfWho[$who].
    " wants to ". $nameOfInfo[$typeOfInfo] .
    ":
    Additional comment was:
    $comment\n";

$mailing = $typeOfInfoPeople[$typeOfInfo][$who];

if (!$mailing)
    die("We apologize. For the moment, we cannot provide feedback for " . $typeOfInforPeople[$who]);
else
    mail($mailing,
      "An information requested",
      $post) or die("Mail session failed! The query was not sent, contact the administrator");
      echo "Email Successful"
?>[/color]
[/table]
[table][tr][td]
[color=blue]<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>
<FORM action="test2.php" method="post">
<SELECT NAME="who">
<OPTION VALUE="1">Prospective insured</option>
<OPTION VALUE="2">Prospective agent</option>
<OPTION VALUE="3">Insured</option>
<OPTION VALUE="4">Agent</option>
<OPTION VALUE="5" selected="selected">Uknown Person</option>
</SELECT>
<select name="typeOfInfo">
<OPTION VALUE="1">Request Claim Information</option>
<OPTION VALUE="2">Request information about my policy</option>
<OPTION VALUE="3">Request information about obtaining my policy</option>
<OPTION VALUE="4">Request my password</option>
<OPTION VALUE="5">Comment on your website</option>
<OPTION VALUE="6">Contact you on an unlisted topic</option>
</select>
<input type="submit" value="Send query">
</form>
</body>

</html>[/color][/table]
Link to comment
https://forums.phpfreaks.com/topic/25738-php-email-different-people/
Share on other sites

Perhaps take a look at this function I wrote for a client here at work.  It sends mail but in a different way -- you take a tpl file (basically php file renamed as a .tpl) -- which opens it and reads it and inputs the info from edata which is an array...  you can use it as you please.

[code]
<?php
  function sendMsg($edata,$content,$subject,$template,$type,$email)
    {
        global $headers; // use html headers from here...
// assign the details and the content to the template
$this->assign('edata', $edata);
        //$this->assign('content', $content); // sets email template
$body = $this->fetch($template.'.tpl');
if($email){
$send_to = $email;
} else {
$send_to = $edata[email];
}

// send the email
return mail($send_to, $subject, $body, $headers);

    }
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.