Form Email Priority

This is a discussion on "Form Email Priority" within the PHP Forum section. This forum, and the thread "Form Email Priority are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 18th, 2005, 14:33
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Form Email Priority

I have a form and one of the fields in it is a Priority selection.

When the High priority is selected I would like the email priority to be set to high - like you can in Outllook Express. Is this possible in PHP?
Reply With Quote

  #2 (permalink)  
Old Aug 19th, 2005, 08:27
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
The fourth parameter of the PHP mail function is headers.

So you'll need something like this (taken from here):
Code: Select all
<?
function MAIL_NVLP($fromname, $fromaddress, $toname, $toaddress, $subject, $message)
{
   // Copyright � 2005 ECRIA LLC, http://www.ECRIA.com
   // Please use or modify for any purpose but leave this notice unchanged.
   $headers  = "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
   $headers .= "X-Priority: 3\n";
   $headers .= "X-MSMail-Priority: Normal\n";
   $headers .= "X-Mailer: php\n";
   $headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
   return mail($toaddress, $subject, $message, $headers);
}
?>
I believe that the highest priority is 1.
Reply With Quote
  #3 (permalink)  
Old Aug 19th, 2005, 09:42
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Hi thanks for this.

Unsure where to put in $Priority==

Do I need to create an if statement for each priority value and put them inside a function? Somethinig like the code below
I dont know php but let me know if I am thinking along the right lines

Code: Select all
<? 
function PLEVEL ($priority) 
{ 
if ($Priority=="1") echo"X-MSMail-Priority: High\n"; 

if ($Priority=="2") echo"X-MSMail-Priority: Normal\n";

if ($Priority=="3") echo"X-MSMail-Priority: Low\n";
} 
?>
If this is about right. How do I then call the PLEVEL function to use it?
Reply With Quote
  #4 (permalink)  
Old Aug 19th, 2005, 09:54
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Or you can use the switch function as explained in your other thread.

Also make sure that $priority in the function header has the same case as $Priority in the function body.
Reply With Quote
  #5 (permalink)  
Old Aug 19th, 2005, 10:18
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Ok I will give the switch function a try thanks.

How do you include the result of a function to an email message?

For example:

$message = "Thank you\n";
$message .= "i would like to add a switch function here: XXXXXX";


I cant figure out the proper typo ??
Reply With Quote
  #6 (permalink)  
Old Aug 21st, 2005, 06:30
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
If the function is using return, then simply call the function inside the string.
Reply With Quote
  #7 (permalink)  
Old Aug 23rd, 2005, 11:07
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Ok

How do I call a function inside a string?
Reply With Quote
  #8 (permalink)  
Old Aug 23rd, 2005, 12:16
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
Just call it...
function(parameters)
Reply With Quote
  #9 (permalink)  
Old Aug 24th, 2005, 11:27
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Why doesn't this work??

I have set up a function named Makeit which holds a Switch function.
I want this to change the X-Priority: and so change to priority of the email. To do this I have attempted to create a variable

$level = Makeit ();

And the line:

$mailheader .= "X-Priority: $level\n";

But there is no data applied to $level. It sends the email but the priority does not change.

I have manualy tested the email priority change and it works. The problem is in calling the function . . please help it is doing my head in . .
. . I am a complete programming numbskull



Code: Select all
<?php
function Makeit ($Priority) 
{
switch ($Priority) 
{
case "Level 1":
   echo "1";
   break;
case "Level 2":
   echo "2";
   break;
case "Level 3":
   echo "3";
   break;
case "Level 4":
   echo "3";
   break;
   }
  } 

$level = Makeit("");

$senderemail = $_POST['Email'];
$recipient = "contact@address.com";
$subject = "CPS Enquiry Form";
$mailheader = "From: $Email\n";
$mailheader .= "Reply-To: $Email\n";
$mailheader .= "MIME-Version: 1.0\n";
$mailheader .= "Content-type: text/plain; charset=iso-8859-1\n"; 
$mailheader .= "X-Priority: $level\n";
$mailheader .= "X-MSMail-Priority: Normal\n";
$mailheader .= "X-Mailer: php\n";


$message = "Blah blah blah blah\n";
$message .= "Blah blah blah blah\n";
?>
Reply With Quote
  #10 (permalink)  
Old Aug 24th, 2005, 18:43
Reputable Member
Join Date: May 2005
Location: Sheffield
Posts: 104
Thanks: 0
Thanked 0 Times in 0 Posts
Right

I sorted it by changing the switch funtions for if statments

and thanks to Sirkent to write a function in a string:

Code: Select all
$mailheader .= "X-Priority: ".$level."\n";
So basically Php is a process of organising Stupid dots and " ." ... """" .. . .""$" ;; ; ; !!!!
Reply With Quote
Reply

Tags
form, email, priority

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP email form not sending email Kurt PHP Forum 1 Oct 12th, 2007 04:26
Form submits to email via php, but email is blank!!?? DH1234 PHP Forum 2 Jun 18th, 2007 10:42
Email form using asp QuizToon Classic ASP 2 Mar 28th, 2006 00:25
Form to Email daveycee Web Page Design 3 Mar 16th, 2006 21:25
php email form djme PHP Forum 3 Jan 1st, 2006 22:06


All times are GMT. The time now is 21:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43