Gobernaster
asked on
PHP Form Mail with Attachment Problem
I have a form on my website that I would like users to be able to fill out, attach a file, and email to me.
The problem I am currently having is that even when an email subject is entered the form says that one has not been entered. Here is the code for my form (as you can tell there is also a config.php and a mail_module.php file- if you need to see the code for them please let me know:
<?
include "config.php";
?>
<form action="mail_module.php" method="post" ENCTYPE="multipart/form-da ta">
<p><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>Email: </strong></font></td>
<td bgcolor="#F0F0F0"><input class=fi type=text size=35 name=email_from value=<? if($mail_mode==0) echo "anonymous@anonymous-serve r.com";?>> </td></tr>
<?
if($mail_mode==0) print("<tr><td bgcolor=\"#F0F0F0\" ><b>TO EMAIL</b></td>
<td bgcolor=\"#F0F0F0\"><input class=fi type=text size=35 name=email_to_anonymous><b r><i>only for testing, please type your real email address</i></td></tr>");
?>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Subject: </font></b></td>
<td><input class=fi type=text size=15 name=email_subject value=<? if($mail_mode==0) echo "Testing of script";?>></td></tr>
</td></tr></table>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td>
<br><p><b><font size="2" face="Arial, Helvetica, sans-serif">Questions, comments, concerns, or general feedback:</font></b>
<br><textarea class=fi name=real_email_message cols=45 rows=8 onclick=createCaret(this); onselect=createCaret(this) ;>
<? if($mail_mode==0) echo "Test message
With blank lines and <b>HTML</b> tags
<hr>
";?>
</textarea></p>
<?
print("
<p>Attachment: <input class=fi type=\"file\" size=32 name=\"upfile\"><br>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$max_size\">
<br><b>Note:</b> We do <b>NOT</b> accept these file types: ");
print(str_replace("|",",", $banned_ex t));
print(". The maximum file size is <b>$max_size</b> Kb");
?>
<p><input class=fb type="submit" value=">> Send email"> <input class=fb type=reset>
<font size=1 color=gray>[MODE :
<?
if($mail_mode==0) echo "Anonymous HTML form mail with attachment file";
else if($mail_mode==1) echo "HTML form mail with attachment file";
?>
]</font>
</td></tr></table>
</form>
Thanks in advance and please be as specific as possible in your responses as this is my first experience with PHP.
-Scott
The problem I am currently having is that even when an email subject is entered the form says that one has not been entered. Here is the code for my form (as you can tell there is also a config.php and a mail_module.php file- if you need to see the code for them please let me know:
<?
include "config.php";
?>
<form action="mail_module.php" method="post" ENCTYPE="multipart/form-da
<p><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>Email:
<td bgcolor="#F0F0F0"><input class=fi type=text size=35 name=email_from value=<? if($mail_mode==0) echo "anonymous@anonymous-serve
<?
if($mail_mode==0) print("<tr><td bgcolor=\"#F0F0F0\" ><b>TO EMAIL</b></td>
<td bgcolor=\"#F0F0F0\"><input
?>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Subject: </font></b></td>
<td><input class=fi type=text size=15 name=email_subject value=<? if($mail_mode==0) echo "Testing of script";?>></td></tr>
</td></tr></table>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td>
<br><p><b><font size="2" face="Arial, Helvetica, sans-serif">Questions, comments, concerns, or general feedback:</font></b>
<br><textarea class=fi name=real_email_message cols=45 rows=8 onclick=createCaret(this);
<? if($mail_mode==0) echo "Test message
With blank lines and <b>HTML</b> tags
<hr>
";?>
</textarea></p>
<?
print("
<p>Attachment: <input class=fi type=\"file\" size=32 name=\"upfile\"><br>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$max_size\">
<br><b>Note:</b> We do <b>NOT</b> accept these file types: ");
print(str_replace("|",",",
print(". The maximum file size is <b>$max_size</b> Kb");
?>
<p><input class=fb type="submit" value=">> Send email"> <input class=fb type=reset>
<font size=1 color=gray>[MODE :
<?
if($mail_mode==0) echo "Anonymous HTML form mail with attachment file";
else if($mail_mode==1) echo "HTML form mail with attachment file";
?>
]</font>
</td></tr></table>
</form>
Thanks in advance and please be as specific as possible in your responses as this is my first experience with PHP.
-Scott
ASKER
mail_module.php:
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2. css">
<?php
//------------------------ ---------- ---------- --
function checkfileatt($fname,$fsize ){
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","", $pos1);
$blist=explode("|",$banned _ext);
for($i=0;$i<sizeof($blist) -1;$i++){
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max _size) $err="ERROR: Your file size (<b>" .round($fsize/1024) ."</b> Kb) is too large. We only accept <b>$max_size</b> Kb. Please click your browser's back button and send a smaller file.";
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n"," <BR>",$tex t);
$text=str_replace("\n","<B R>",$text) ;
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\. -]+@[A-za- z0-9\_\.-] +.[A-za-z0 -9\_-]+.*" ,$email) || empty($email))
return FALSE;
else return TRUE;
}
//------------------------ ---------- ---------- --
if($mail_mode==0) $email_to=$email_to_anonym ous;
else $email_to=$my_email;
if($version=="demo") {
$email_from="anonymous@ano nymous-ser ver.com";
$real_email_message.="<br> ---------- --<br>Demo email sent from <a href=http://obiewebsite.sourceforge.net target=_blank>http://ObieWebsite.SourceForge.Net</a><br>Get more PHP and Javascripts for FREE!<br>";
}
$kt=0;
//Checking valid email address
if(!checkemail($email_to)) $kt=1;
if(!checkemail($email_from )) $kt=1;
if(empty($email_subject)) $kt=2;
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------ ---------- ---------- --
$email_message=formathtml( $real_emai l_message) ;
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name ,$upfile_s ize)!="No file attached") $chked=1;
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type ;
$fileatt_name=$upfile_name ;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file att));
fclose($file);
}
$headers = "From: ".$email_from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s emi_rand}x ";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary }\"";
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding : 7bit\n\n" . $email_message . "\n\n";
$data = chunk_split(base64_encode( $data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n " . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name} \"\n" . "Content-Transfer-Encoding : base64\n\n" . $data . "\n\n" ."--{$mime_boundary}--\n";
$sending_ok = @mail($email_to, $email_subject, $email_message, $headers);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//----------------------- ---------- ---------- ---
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p >
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema il_message ));
print("</td></tr></table>< p><br></p>
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name< /b><br>Fil esize: " .round($upfile_size/1024) ." Kb | Filetype : $upfile_type");
else print("<p>" .checkfileatt($upfile_name ,$upfile_s ize) ."</p>");
}
}
?>
Thanks!
-Scott
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2.
<?php
//------------------------
function checkfileatt($fname,$fsize
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",
$blist=explode("|",$banned
for($i=0;$i<sizeof($blist)
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n","
$text=str_replace("\n","<B
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\.
return FALSE;
else return TRUE;
}
//------------------------
if($mail_mode==0) $email_to=$email_to_anonym
else $email_to=$my_email;
if($version=="demo") {
$email_from="anonymous@ano
$real_email_message.="<br>
}
$kt=0;
//Checking valid email address
if(!checkemail($email_to))
if(!checkemail($email_from
if(empty($email_subject)) $kt=2;
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------
$email_message=formathtml(
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type
$fileatt_name=$upfile_name
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file
fclose($file);
}
$headers = "From: ".$email_from;
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding
$data = chunk_split(base64_encode(
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n
$sending_ok = @mail($email_to, $email_subject, $email_message, $headers);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//-----------------------
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema
print("</td></tr></table><
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name<
else print("<p>" .checkfileatt($upfile_name
}
}
?>
Thanks!
-Scott
hi,
your script appears to be assuming register_globals is on when it is most probably not. you can check by putting <? phpinfo(); ?> in a script and looking for the value of register_globals in it. register_globals puts values from forms, sessions, cookies, urls etc. into direct variable names, so an input field with name="myformfield" would come out as $myformfield on the next page. however if register globals is off, it will be put into the variable $_POST as part of an array, so it would be accessed through $_POST["myformfield"] (assuming the method of the form is POST). the reason for having register_globals off is that it's a security risk if values can come from any source. for example if your login system relied on a session variable called logged_in being present, a user could go to the page.php?logged_in=1 and this would bluff being authenticated
so in a nutshell, what you need to do is replace any instances of variables that come from your form with the register_globals equivalent. values from your POST form becomes $_POST["fieldname"] and your file upload variables become $_FILES["fieldname"]
so email_to becomes $_POST["email_to"], email_to_anonymous becomes $_POST["email_to_anonymous "], $email_subject value becomes $_POST["email_subject value"] etc. info about your upload comes from $_FILES["upfile"]["tmp_nam e"], $_FILES["upfile"]["name"] etc
if you're using php 4.1.0 or earlier, you need to use the old forms of these variables, which are HTTP_POST_VARS["fieldname" ] and $HTTP_POST_FILES["fieldnam e"]
to read more, go here: http://uk2.php.net/variables.predefined
loz
your script appears to be assuming register_globals is on when it is most probably not. you can check by putting <? phpinfo(); ?> in a script and looking for the value of register_globals in it. register_globals puts values from forms, sessions, cookies, urls etc. into direct variable names, so an input field with name="myformfield" would come out as $myformfield on the next page. however if register globals is off, it will be put into the variable $_POST as part of an array, so it would be accessed through $_POST["myformfield"] (assuming the method of the form is POST). the reason for having register_globals off is that it's a security risk if values can come from any source. for example if your login system relied on a session variable called logged_in being present, a user could go to the page.php?logged_in=1 and this would bluff being authenticated
so in a nutshell, what you need to do is replace any instances of variables that come from your form with the register_globals equivalent. values from your POST form becomes $_POST["fieldname"] and your file upload variables become $_FILES["fieldname"]
so email_to becomes $_POST["email_to"], email_to_anonymous becomes $_POST["email_to_anonymous
if you're using php 4.1.0 or earlier, you need to use the old forms of these variables, which are HTTP_POST_VARS["fieldname"
to read more, go here: http://uk2.php.net/variables.predefined
loz
ASKER
loz,
You are correct- I checked and register_globals is off. The PHP version is 4.2.2.
I changed my form to this:
<?
include "config.php";
?>
<form action="mail_module.php" method="post" ENCTYPE="multipart/form-da ta">
<p><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>Email: </strong></font></td>
<td bgcolor="#F0F0F0"><input class=fi type=text size=35 name=$_POST["email_from value"]=<? if($mail_mode==0) echo "anonymous@anonymous-serve r.com";?>> </td></tr>
<?
if($mail_mode==0) print("<tr><td bgcolor=\"#F0F0F0\" ><b>TO EMAIL</b></td>
<td bgcolor=\"#F0F0F0\"><input class=fi type=text size=35 name=$_POST["email_to_anon ymous"]><b r><i>only for testing, please type your real email address</i></td></tr>");
?>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Subject: </font></b></td>
<td><input class=fi type=text size=15 name=$_POST["email_subject value"]=<? if($mail_mode==0) echo "Testing of script";?>></td></tr>
</td></tr></table>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td>
<br><p><b><font size="2" face="Arial, Helvetica, sans-serif">Questions, comments, concerns, or general feedback:</font></b>
<br><textarea class=fi name=$_POST["real_email_me ssage"] cols=45 rows=8 onclick=createCaret(this); onselect=createCaret(this) ;>
<? if($mail_mode==0) echo "Test message
With blank lines and <b>HTML</b> tags
<hr>
";?>
</textarea></p>
<?
print("
<p>Attachment: <input class=fi type=\"file\" size=32 name=$_FILES["upfile"]["na me"]><br>
<input type=\"hidden\" name=$_FILES["MAX_FILE_SIZ E"] value=\"$max_size\">
<br><b>Note:</b> We do <b>NOT</b> accept these file types: ");
print(str_replace("|",",", $banned_ex t));
print(". The maximum file size is <b>$max_size</b> Kb");
?>
<p><input class=fb type="submit" value=">> Send email"> <input class=fb type=reset>
<font size=1 color=gray>[MODE :
<?
if($mail_mode==0) echo "Anonymous HTML form mail with attachment file";
else if($mail_mode==1) echo "HTML form mail with attachment file";
?>
]</font>
</td></tr></table>
</form>
but now nothing shows up when I go to the PHP page. I am sure it is something stupid that I did, but please bear with me as I have never dealt with PHP before.
Do I need to make any changes to the config or mail_module files?
Thanks!!
You are correct- I checked and register_globals is off. The PHP version is 4.2.2.
I changed my form to this:
<?
include "config.php";
?>
<form action="mail_module.php" method="post" ENCTYPE="multipart/form-da
<p><table border=0 cellspacing=0 cellpadding=0>
<tr>
<td><font size="2" face="Arial, Helvetica, sans-serif"><strong>Email:
<td bgcolor="#F0F0F0"><input class=fi type=text size=35 name=$_POST["email_from value"]=<? if($mail_mode==0) echo "anonymous@anonymous-serve
<?
if($mail_mode==0) print("<tr><td bgcolor=\"#F0F0F0\" ><b>TO EMAIL</b></td>
<td bgcolor=\"#F0F0F0\"><input
?>
<tr>
<td><b><font size="2" face="Arial, Helvetica, sans-serif">Subject: </font></b></td>
<td><input class=fi type=text size=15 name=$_POST["email_subject
</td></tr></table>
<table border=0 cellspacing=0 cellpadding=0>
<tr><td>
<br><p><b><font size="2" face="Arial, Helvetica, sans-serif">Questions, comments, concerns, or general feedback:</font></b>
<br><textarea class=fi name=$_POST["real_email_me
<? if($mail_mode==0) echo "Test message
With blank lines and <b>HTML</b> tags
<hr>
";?>
</textarea></p>
<?
print("
<p>Attachment: <input class=fi type=\"file\" size=32 name=$_FILES["upfile"]["na
<input type=\"hidden\" name=$_FILES["MAX_FILE_SIZ
<br><b>Note:</b> We do <b>NOT</b> accept these file types: ");
print(str_replace("|",",",
print(". The maximum file size is <b>$max_size</b> Kb");
?>
<p><input class=fb type="submit" value=">> Send email"> <input class=fb type=reset>
<font size=1 color=gray>[MODE :
<?
if($mail_mode==0) echo "Anonymous HTML form mail with attachment file";
else if($mail_mode==1) echo "HTML form mail with attachment file";
?>
]</font>
</td></tr></table>
</form>
but now nothing shows up when I go to the PHP page. I am sure it is something stupid that I did, but please bear with me as I have never dealt with PHP before.
Do I need to make any changes to the config or mail_module files?
Thanks!!
hi,
you don't need to change your form at all - it's only your mail_module page which needs modification so if you put the form back to how it was and replace the instances of variables which come from the form with the ones i gave you, it should work properly
tell me if you have any more problems
cheers,
loz
you don't need to change your form at all - it's only your mail_module page which needs modification so if you put the form back to how it was and replace the instances of variables which come from the form with the ones i gave you, it should work properly
tell me if you have any more problems
cheers,
loz
ASKER
Thanks loz,
I removed the changes from my form and made the changes to the mail_module file but I am still having some problems. Now it says the email address is not correct.
Again I apologize for being such a pain, but I really have no idea what I am doing (which I am sure you already figured by now).
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2. css">
<?php
//------------------------ ---------- ---------- --
function checkfileatt($fname,$fsize ){
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","", $pos1);
$blist=explode("|",$banned _ext);
for($i=0;$i<sizeof($blist) -1;$i++){
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max _size) $err="ERROR: Your file size (<b>" .round($fsize/1024) ."</b> Kb) is too large. We only accept <b>$max_size</b> Kb. Please click your browser's back button and send a smaller file.";
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n"," <BR>",$tex t);
$text=str_replace("\n","<B R>",$text) ;
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\. -]+@[A-za- z0-9\_\.-] +.[A-za-z0 -9\_-]+.*" ,$email) || empty($email))
return FALSE;
else return TRUE;
}
//------------------------ ---------- ---------- --
if($mail_mode==0) $_POST["email_to"]=$_POST[ "email_to_ anonymous" ];
else $_POST["email_to"]=$_POST[ "my_email" ];
if($version=="demo") {
$_POST["email_from"]=$_POS T["anonymo us@anonymo us-server. com"];
$_POST["real_email_message "].="<br>- ---------- -<br>Demo email sent from <a href=http://obiewebsite.sourceforge.net target=_blank>http://ObieWebsite.SourceForge.Net</a><br>Get more PHP and Javascripts for FREE!<br>";
}
$kt=0;
//Checking valid email address
if(!checkemail($_POST["ema il_to"])) $kt=1;
if(!checkemail($_POST["ema il_from"]) ) $kt=1;
if(empty($_POST["email_sub ject"])) $kt=2;
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------ ---------- ---------- --
$email_message=formathtml( $real_emai l_message) ;
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name ,$upfile_s ize)!="No file attached") $chked=1;
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type ;
$fileatt_name=$upfile_name ;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file att));
fclose($file);
}
$headers = "From: ".$_POST["email_from"];
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s emi_rand}x ";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary }\"";
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding : 7bit\n\n" . $email_message . "\n\n";
$data = chunk_split(base64_encode( $data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n " . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name} \"\n" . "Content-Transfer-Encoding : base64\n\n" . $data . "\n\n" ."--{$mime_boundary}--\n";
$sending_ok = @mail($_POST["email_to"], $_POST["email_subject"], $_POST["email_message"], $_POST["headers"]);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//----------------------- ---------- ---------- ---
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p >
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema il_message ));
print("</td></tr></table>< p><br></p>
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name< /b><br>Fil esize: " .round($upfile_size/1024) ." Kb | Filetype : $upfile_type");
else print("<p>" .checkfileatt($upfile_name ,$upfile_s ize) ."</p>");
}
}
?>
Thank you for your patience!
I removed the changes from my form and made the changes to the mail_module file but I am still having some problems. Now it says the email address is not correct.
Again I apologize for being such a pain, but I really have no idea what I am doing (which I am sure you already figured by now).
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2.
<?php
//------------------------
function checkfileatt($fname,$fsize
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",
$blist=explode("|",$banned
for($i=0;$i<sizeof($blist)
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n","
$text=str_replace("\n","<B
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\.
return FALSE;
else return TRUE;
}
//------------------------
if($mail_mode==0) $_POST["email_to"]=$_POST[
else $_POST["email_to"]=$_POST[
if($version=="demo") {
$_POST["email_from"]=$_POS
$_POST["real_email_message
}
$kt=0;
//Checking valid email address
if(!checkemail($_POST["ema
if(!checkemail($_POST["ema
if(empty($_POST["email_sub
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------
$email_message=formathtml(
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type
$fileatt_name=$upfile_name
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file
fclose($file);
}
$headers = "From: ".$_POST["email_from"];
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding
$data = chunk_split(base64_encode(
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n
$sending_ok = @mail($_POST["email_to"], $_POST["email_subject"], $_POST["email_message"], $_POST["headers"]);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//-----------------------
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema
print("</td></tr></table><
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name<
else print("<p>" .checkfileatt($upfile_name
}
}
?>
Thank you for your patience!
i assume this is your error message: ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.
which occurs due to this:
if(!checkemail($_POST["ema il_to"])) $kt=1;
if(!checkemail($_POST["ema il_from"]) ) $kt=1;
which leads me back to:
if($mail_mode==0) $_POST["email_to"]=$_POST[ "email_to_ anonymous" ];
else $_POST["email_to"]=$_POST[ "my_email" ];
this should actually be
if($mail_mode==0) $email_to=$_POST["email_to _anonymous "];
else $email_to=$my_email
i'm guessing $mail_mode and $my_email are set in config.php..
there might be some more problems anyway
loz
which occurs due to this:
if(!checkemail($_POST["ema
if(!checkemail($_POST["ema
which leads me back to:
if($mail_mode==0) $_POST["email_to"]=$_POST[
else $_POST["email_to"]=$_POST[
this should actually be
if($mail_mode==0) $email_to=$_POST["email_to
else $email_to=$my_email
i'm guessing $mail_mode and $my_email are set in config.php..
there might be some more problems anyway
loz
ASKER
Thanks! I replaced this:
if($mail_mode==0) $_POST["email_to"]=$_POST[ "email_to_ anonymous" ];
else $_POST["email_to"]=$_POST[ "my_email" ];
with this:
if($mail_mode==0) $email_to=$_POST["email_to _anonymous "];
else $email_to=$my_email
I no longer receive the error "Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address," but now the mail_module.php page shows up blank after filling out the form and clicking submit.
And yes, mail_mode and $my_email are set in config.php.
if($mail_mode==0) $_POST["email_to"]=$_POST[
else $_POST["email_to"]=$_POST[
with this:
if($mail_mode==0) $email_to=$_POST["email_to
else $email_to=$my_email
I no longer receive the error "Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address," but now the mail_module.php page shows up blank after filling out the form and clicking submit.
And yes, mail_mode and $my_email are set in config.php.
$sending_ok = @mail($_POST["email_to"], $_POST["email_subject"], $_POST["email_message"], $_POST["headers"]);
this needs to be changed to
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
i don't imagine this will fix it but it's worth a go, and needs changing anyway.. what would probably be best is to debug by adding print "1"; print "2"; etc. after certain sections of code so you can find the spot where the code stops working
loz
this needs to be changed to
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
i don't imagine this will fix it but it's worth a go, and needs changing anyway.. what would probably be best is to debug by adding print "1"; print "2"; etc. after certain sections of code so you can find the spot where the code stops working
loz
ASKER
Thanks loz, I replaced:
$sending_ok = @mail($_POST["email_to"], $_POST["email_subject"], $_POST["email_message"], $_POST["headers"]);
with:
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
but as you had assume it still isn't fixed- I still end up at a blank mail_module page after filling out the form and clicking submit.
after what sections of code would you suggest I add print "1"; print "2"? (again, sorry, but I don't even possess a basic understanding of PHP and am totally lost- as I am sure you can tell, but really wanted to get this form working)
Thanks so much!
$sending_ok = @mail($_POST["email_to"], $_POST["email_subject"], $_POST["email_message"], $_POST["headers"]);
with:
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
but as you had assume it still isn't fixed- I still end up at a blank mail_module page after filling out the form and clicking submit.
after what sections of code would you suggest I add print "1"; print "2"? (again, sorry, but I don't even possess a basic understanding of PHP and am totally lost- as I am sure you can tell, but really wanted to get this form working)
Thanks so much!
adding that where each double line break is would probably work ok, would help to narrow it down, then you can tell me which is the last number it prints out and where the number is added in
cheers,
loz
cheers,
loz
ASKER
I tried adding print "1"; print "2"; etc. into the mail_module code and the page still loads blank...
Are there certain areas or ways to add these print commands that I don't know?
Are there certain areas or ways to add these print commands that I don't know?
can you paste all the code from mail_module.php here
loz
loz
ASKER
do you want me to include all the html too?
would it make it easier for you if I sent the file to you?
Thanks,
Scott
would it make it easier for you if I sent the file to you?
Thanks,
Scott
ASKER
Here's mail_module:
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2. css">
<?php
//------------------------ ---------- ---------- --
function checkfileatt($fname,$fsize ){
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","", $pos1);
$blist=explode("|",$banned _ext);
for($i=0;$i<sizeof($blist) -1;$i++){
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max _size) $err="ERROR: Your file size (<b>" .round($fsize/1024) ."</b> Kb) is too large. We only accept <b>$max_size</b> Kb. Please click your browser's back button and send a smaller file.";
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n"," <BR>",$tex t);
$text=str_replace("\n","<B R>",$text) ;
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\. -]+@[A-za- z0-9\_\.-] +.[A-za-z0 -9\_-]+.*" ,$email) || empty($email))
return FALSE;
else return TRUE;
}
//------------------------ ---------- ---------- --
if($mail_mode==0) $email_to=$_POST["email_to _anonymous "];
else $email_to=$my_email
if($version=="demo") {
$_POST["email_from"]=$_POS T["anonymo us@anonymo us-server. com"];
$_POST["real_email_message "].="<br>- ---------- -<br>Demo email sent from <a href=http://obiewebsite.sourceforge.net target=_blank>http://ObieWebsite.SourceForge.Net</a><br>Get more PHP and Javascripts for FREE!<br>";
}
$kt=0;
//Checking valid email address
if(!checkemail($_POST["ema il_to"])) $kt=1;
if(!checkemail($_POST["ema il_from"]) ) $kt=1;
if(empty($_POST["email_sub ject"])) $kt=2;
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------ ---------- ---------- --
$email_message=formathtml( $real_emai l_message) ;
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name ,$upfile_s ize)!="No file attached") $chked=1;
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type ;
$fileatt_name=$upfile_name ;
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file att));
fclose($file);
}
$headers = "From: ".$_POST["email_from"];
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s emi_rand}x ";
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary }\"";
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding : 7bit\n\n" . $email_message . "\n\n";
$data = chunk_split(base64_encode( $data));
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n " . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name} \"\n" . "Content-Transfer-Encoding : base64\n\n" . $data . "\n\n" ."--{$mime_boundary}--\n";
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//----------------------- ---------- ---------- ---
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p >
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema il_message ));
print("</td></tr></table>< p><br></p>
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name< /b><br>Fil esize: " .round($upfile_size/1024) ." Kb | Filetype : $upfile_type");
else print("<p>" .checkfileatt($upfile_name ,$upfile_s ize) ."</p>");
}
}
?>
<?
include "config.php";
?>
<link rel=stylesheet href="../style/formstyle2.
<?php
//------------------------
function checkfileatt($fname,$fsize
global $max_size;
global $banned_ext;
$err="No file attached";
//Checking file type in or out of banned file extensions list
$pos1=strrchr($fname,".");
$ftype=str_replace(".","",
$blist=explode("|",$banned
for($i=0;$i<sizeof($blist)
if($ftype==$blist[$i]) $err="ERROR: Your file extension (<b>*.$ftype</b>) is not be accepted. Please click your browser's back button and submit an acceptable file.";
}
//Check file size
if(round($fsize/1024)>$max
//Return the value
return $err;
}
function formathtml($text){
$text=stripslashes($text);
$text=str_replace("\r\n","
$text=str_replace("\n","<B
return $text;
}
function checkemail($email){
if(!eregi("^[A-za-z0-9\_\.
return FALSE;
else return TRUE;
}
//------------------------
if($mail_mode==0) $email_to=$_POST["email_to
else $email_to=$my_email
if($version=="demo") {
$_POST["email_from"]=$_POS
$_POST["real_email_message
}
$kt=0;
//Checking valid email address
if(!checkemail($_POST["ema
if(!checkemail($_POST["ema
if(empty($_POST["email_sub
if($kt==1) print("<p>ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address.</p>");
else if($kt==2) print("<p>ERROR: Your email subject is blank. Please click your browser's back button and enter a subject.</p>");
if($kt==0){
//BEGIN //------------------------
$email_message=formathtml(
$chked=0;
if ($upfile == "none" || $upfile_size==0) $chked=1;
if (checkfileatt($upfile_name
if($chked==0) {
copy($upfile, $upfile_name);
$fileatt=$upfile_name;
$fileatt_type=$upfile_type
$fileatt_name=$upfile_name
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($file
fclose($file);
}
$headers = "From: ".$_POST["email_from"];
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$s
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary
$email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding
$data = chunk_split(base64_encode(
$email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
if($chked==0) unlink($upfile_name);
//END mode 3 and 0//-----------------------
//Print the email result
if($sending_ok){
print("<title>Sending successful to $email_to</title><div align=center><p>Your email was sent successfully!!</p>");
}
else print("<title>Sending failed to $email_to</title><div align=center><p><b>ERROR in mail server</b>Sorry, your email could not be sent at this time.</p>");
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$email_from
<p><u><b>Email subject</b></u><br>
$email_subject
<p><u><b>Message</b></u><p
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($real_ema
print("</td></tr></table><
<p align=center><a href=../index.htm title=\"Come back to my site\">Thank you!! Back to my site</a> or <a href=index.php>send me another email.</a></p>
<p><br></p>
</td></tr></table>
<p><b>Attachment status</b>
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>");
if($mail_mode==0 || $mail_mode==1) {
if($chked==0) print("<p><b>$upfile_name<
else print("<p>" .checkfileatt($upfile_name
}
}
?>
if($mail_mode==0) $email_to=$_POST["email_to _anonymous "];
else $email_to=$my_email
the 2nd line here is missing a semi colon at the end:
if($mail_mode==0) $email_to=$_POST["email_to _anonymous "];
else $email_to=$my_email;
if that doesn't work i'll have to give you some more help tomorrow
cheers,
loz
else $email_to=$my_email
the 2nd line here is missing a semi colon at the end:
if($mail_mode==0) $email_to=$_POST["email_to
else $email_to=$my_email;
if that doesn't work i'll have to give you some more help tomorrow
cheers,
loz
ASKER
Now the mail_module pages loads as it should, but I get this error "ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address."
Thanks for all of your help today and I'll talk to you tomorrow!
Thanks for all of your help today and I'll talk to you tomorrow!
ASKER
loz,
hate to bother you any more, but are you available for some additional guidance?
-Scott
hate to bother you any more, but are you available for some additional guidance?
-Scott
whoops, sorry must have missed your last message..
change if(!checkemail($_POST["ema il_to"])) $kt=1; to if(!checkemail($email_to)) $kt=1;
sorry again
loz
change if(!checkemail($_POST["ema
sorry again
loz
ASKER
No big deal, thanks loz!
I no longer receive the "ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address," but now receive this error after clicking Send email, "ERROR in mail serverSorry, your email could not be sent at this time."
Do I need to make similar changes to:
if(!checkemail($_POST["ema il_from"]) ) $kt=1;
if(empty($_POST["email_sub ject"])) $kt=2;
or do these lines remain the same and the problem lies elsewhere?
Thanks!!!
I no longer receive the "ERROR: Email address (From email or To email) is not correct. Please click your browser's back button and enter your email address," but now receive this error after clicking Send email, "ERROR in mail serverSorry, your email could not be sent at this time."
Do I need to make similar changes to:
if(!checkemail($_POST["ema
if(empty($_POST["email_sub
or do these lines remain the same and the problem lies elsewhere?
Thanks!!!
ASKER
Any idea on what is wrong now (please see previous post for details)?
heh, missed it again.. sorry i was working all last night
$email_message=formathtml( $real_emai l_message) ;
that should be
$email_message=formathtml( $_POST["re al_email_m essage"]);
if it's coming through from the form. remove the @ from the following line:
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
then we'll go from there
loz
$email_message=formathtml(
that should be
$email_message=formathtml(
if it's coming through from the form. remove the @ from the following line:
$sending_ok = @mail($email_to, $_POST["email_subject"], $email_message, $headers);
then we'll go from there
loz
ASKER
Thanks loz I changed this:
"$email_message=formathtml ($real_ema il_message );"
to
"$email_message=formathtml ($_POST["r eal_email_ message"]) ;"
but I still get "ERROR in mail server. Sorry, your email could not be sent at this time." I tried it both with the @ and without it and had the same result.
Also, the "From email," "Email subject," and "Message" are all blank on the mail_module page after submitting the form. The only field that shows up filled in is "Sent to email."
"$email_message=formathtml
to
"$email_message=formathtml
but I still get "ERROR in mail server. Sorry, your email could not be sent at this time." I tried it both with the @ and without it and had the same result.
Also, the "From email," "Email subject," and "Message" are all blank on the mail_module page after submitting the form. The only field that shows up filled in is "Sent to email."
hi,
they're blank in the form because they are the wrong variables - you need to have $_POST in front of email_from and email_subject, same for real_email_message
just before: $sending_ok = mail($email_to, $_POST["email_subject"], $email_message, $headers);
could you add: print "$email_to - " . $_POST["email_subject"] . " - $email_message - $headers";
and give me the output?
thanks,
loz
they're blank in the form because they are the wrong variables - you need to have $_POST in front of email_from and email_subject, same for real_email_message
just before: $sending_ok = mail($email_to, $_POST["email_subject"], $email_message, $headers);
could you add: print "$email_to - " . $_POST["email_subject"] . " - $email_message - $headers";
and give me the output?
thanks,
loz
ASKER
Thanks loz,
Here's the output,
"gobernaster@hotmail.com - site - This is a multi-part message in MIME format. --==Multipart_Boundary_x68 1e833a69e0 d1565eaa64 191ae5c310 x Content-Type:text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit --==Multipart_Boundary_x68 1e833a69e0 d1565eaa64 191ae5c310 x Content-Type: ; name="" Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 --==Multipart_Boundary_x68 1e833a69e0 d1565eaa64 191ae5c310 x-- - From: gobernaster@hotmail.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="==Multipart_Boun dary_x681e 833a69e0d1 565eaa6419 1ae5c310x"
Here's the output,
"gobernaster@hotmail.com - site - This is a multi-part message in MIME format. --==Multipart_Boundary_x68
can you make a seperate script and run it, filling in your email address for the first argument of each function:
<?
mail("myemail@email.com", "My Subject", "Line 1\nLine 2\nLine 3");
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."Reply-To: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."X-Mailer: PHP/" . phpversion());
?>
tell me if you get both emails through. be back tomorrow to try and help some more
loz
<?
mail("myemail@email.com", "My Subject", "Line 1\nLine 2\nLine 3");
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE
."Reply-To: webmaster@{$_SERVER['SERVE
."X-Mailer: PHP/" . phpversion());
?>
tell me if you get both emails through. be back tomorrow to try and help some more
loz
ASKER
I added the $_Post in front of email_from, email_subject, and real_email_message, but now the mail_module page does not load (it is completely blank after submitting the form). Below is the new code I am using...
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$_POST["email_from"]
<p><u><b>Email subject</b></u><br>
$_POST["email_subject"]
<p><u><b>Message</b></u><p >
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($_POST["r eal_email_ message"]) );
-Scott
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>
$_POST["email_from"]
<p><u><b>Email subject</b></u><br>
$_POST["email_subject"]
<p><u><b>Message</b></u><p
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($_POST["r
-Scott
the double quotes cause it to break
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>" .
$_POST["email_from"] . "
<p><u><b>Email subject</b></u><br>" .
$_POST["email_subject"] . "
<p><u><b>Message</b></u><p >
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($_POST["r eal_email_ message"]) );
loz
print("
<p><table border=0 width=770 cellspacing=1 bgcolor=black><tr><td bgcolor=gray>
<p><u><b>Sent to email</b></u><br>
$email_to
<p><u><b>From email</b></u><br>" .
$_POST["email_from"] . "
<p><u><b>Email subject</b></u><br>" .
$_POST["email_subject"] . "
<p><u><b>Message</b></u><p
<table border=0 width=770 cellspacing=1 style=\"border: 1 dotted #AED0F2;\"><tr><td>");
print(formathtml($_POST["r
loz
ASKER
Thanks loz, I applied the code from your last post and now the email from, email subject, and email message fields appear filled in on the mail_module page (I know you knew this would work, but just wanted to update you)!!
Am I placing this:
<?
mail("myemail@email.com", "My Subject", "Line 1\nLine 2\nLine 3");
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."Reply-To: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."X-Mailer: PHP/" . phpversion());
?>
in the same mail_module file or in a completely separate file?
Am I placing this:
<?
mail("myemail@email.com", "My Subject", "Line 1\nLine 2\nLine 3");
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE
."Reply-To: webmaster@{$_SERVER['SERVE
."X-Mailer: PHP/" . phpversion());
?>
in the same mail_module file or in a completely separate file?
seperate file, run it once, simply to test if the mailing on your server is working (remember to replace the address in there)
loz
loz
ASKER
loz,
Sorry that I didn't have time to respond yesterday, but I was extremely busy with other stuff and couldn't find the time to get on a computer.
I added this to a new page and uploaded it to my server:
<?
mail("gobernaster@hotmail. com", "Mail Server Test", "Line 1\nLine 2\nLine 3");
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."Reply-To: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."X-Mailer: PHP/" . phpversion());
?>
I then visited this page on my server via IE and later checked my email, but never received anything. I was not clear on where I had to enter my email address so I also tried:
<?
mail("gobernaster@hotmail. com", "Mail Server Test", "Line 1\nLine 2\nLine 3");
mail("gobernaster@hotmail. com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."Reply-To: webmaster@{$_SERVER['SERVE R_NAME']}\ r\n"
."X-Mailer: PHP/" . phpversion());
?>
Am I doing something wrong or does this mean there is a problem with the mailing on my server?
Thanks!
-Scott
Sorry that I didn't have time to respond yesterday, but I was extremely busy with other stuff and couldn't find the time to get on a computer.
I added this to a new page and uploaded it to my server:
<?
mail("gobernaster@hotmail.
mail("myemail@email.com", "the subject", $message,
"From: webmaster@{$_SERVER['SERVE
."Reply-To: webmaster@{$_SERVER['SERVE
."X-Mailer: PHP/" . phpversion());
?>
I then visited this page on my server via IE and later checked my email, but never received anything. I was not clear on where I had to enter my email address so I also tried:
<?
mail("gobernaster@hotmail.
mail("gobernaster@hotmail.
"From: webmaster@{$_SERVER['SERVE
."Reply-To: webmaster@{$_SERVER['SERVE
."X-Mailer: PHP/" . phpversion());
?>
Am I doing something wrong or does this mean there is a problem with the mailing on my server?
Thanks!
-Scott
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey loz,
I am using FSIwebs to host this site. I will contact my admin over there to try to work through this and will let you know how I make out.
Thanks for all of your help so far and I'll keep you posted!!
-Scott
I am using FSIwebs to host this site. I will contact my admin over there to try to work through this and will let you know how I make out.
Thanks for all of your help so far and I'll keep you posted!!
-Scott
ASKER
Sorry loz this fell to the backburner and is still an issue. You did a significant amount of work to help me out and I will reward you the points despite my lack of a solution.
loz