PDA

View Full Version : Firefox 3 and auto MailTo


paulm
11-13-2008, 05:30 PM
I am trying to code a javascript contact form but am experiencing a problem with firefox 3. It seems that it automatically wants to open up the users default email site ( gmail, yahoo ). Instead of sending the email automatically. I know that I can do this with PHP, but I always thought it could be done just as easily with javascript. I have tested it in IE and I only get that message asking to confirm.

So my question is. Is how can I get it to send the email without opening up there default email provider, using javascript. Here is some of my code:


<form enctype="text/plain" name="addform" method='get'action='mailto:...?subject=Welcome Pages - Mailing Test' onSubmit="return submitForms()">
<input type="hidden" name="Form" value="Submit Sub">



<table border="0" style="margin-top:50px; " cellpadding="2" cellspacing="5">
<tr>
<td align="left" valign="bottom" width="50%">
<p>Full Name: <br />
<input type=text name="Full Name" size=30,1 maxlength=40></p>
</td>

<td align="left" valign="bottom">
<p>Email Address: <br />
<input type=text name="Email Address" size=30,1 maxlength=40></p>
</td>
</tr>



<tr>
<td align="left" valign="bottom">
<p>OREA Student ID: <br />
<input type=text name="Student ID" size=30,1 maxlength=8></p>
</td>

<td align="left" valign="bottom">
<p>Prefered Contact Number: <br />
<input type=text name="Phone Number" size=30,1 maxlength=20></p>
</td>
</tr>



<tr>
<td align="left" valign="bottom">
<p>Operating System: <br />
<input type=text name="Operating System" size=30,1 maxlength=40></p>
</td>


<td align="left" valign="bottom">
<p>Web Browser: <br />
<span style="font-size:10px;"> ( e.g. Firefox, Internet Explorer 6, Safari ) </span> <br />
<input type=text name="Broswer" size=30,1 maxlength=40></p>
</td>
</tr>



<tr>
<td align="center" colspan="2" valign="bottom">
<p>Session/Module where issue was encountered <br />
<input type=text name="Issue" size=50,1 maxlength=40></p>
</td>
</tr>



<tr>
<td align="center" colspan="2" valign="bottom">
<p>Briefly describe the problem you are having: <br />
<textarea name="Description" cols="50,2" rows="5" ></textarea></p>
</td>
</tr>

</table>

<p style="font-size:10px;">All personal information received is kept confidential.</p>

<input type="submit" value=" Submit ">
<input type="button" value=" Return " onclick="window.location='...'">
<input type="reset" value="Reset Form" onclick=resetform()>

</table>

</form>

paulm
11-14-2008, 01:31 PM
Well I decided to go with php. But I am having some trouble getting it working. I have tried several different templates off of websites and none seem to work. I am starting to think it is because of the server I am testing off of. I know php is enabled, but could it be blocking the mail function. I ran a test page to get the php info for the host, but I don't know how to tell if it is being blocked or not. Can anyone help me out.


Just in case here is the code for the contact form:





contact.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>

<form method="post" action="sendemail.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
<br />
Attention:<br />
<select name="attn" size="1">
<option value=" Sales n Billing ">Sales n Billing </option>
<option value=" General Support ">General Support </option>
<option value=" Technical Support ">Technical Support </option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br /><br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
<br />
</form>

</body>
</html>






sendmail.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sendemail Script</title>
</head>
<body>

<!-- Reminder: Add the link for the 'next page' (at the bottom) -->
<!-- Reminder: Change 'YourEmail' to Your real email -->

<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['visitor'];
$visitormail = $_POST['visitormail'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];


if (eregi('http:', $notes)) {
die ("Do NOT try that! ! ");
}
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n";
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
echo $badinput;
die ("Go back! ! ");
}

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
die ("Use back! ! ");
}

$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
Attention: $attn \n
Message: $notes \n
From: $visitor ($visitormail)\n
Additional Info : IP = $ip \n
Browser Info: $httpagent \n
Referral : $httpref \n
";

$from = "From: $visitormail\r\n";


mail(" *** EMAIL HERE *** ", $subject, $message, $from);

?>

<p align="center">
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> )
<br />

Attention: <?php echo $attn ?>
<br />
Message:<br />
<?php $notesout = str_replace("\r", "<br/>", $notes);
echo $notesout; ?>
<br />
<?php echo $ip ?>

<br /><br />
<a href="contact.php"> Next Page </a>
</p>

</body>
</html>