help! email script won't send email

totheletter

New Member
i have an email script on my page and when i send it, i never receive the emails on the other. I can't figure out why it isn't sending, I'm sure there is something small wrong in the code that I can't catch since I don't know what to look for. Anyone got any ideas? Any help is appreciated


Contact.php ------> the page that contains the email form. here is the coding

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

<?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 ?>" />

Department:<br />
<select name="attn" size="1">
<option value=" Sales ">Sales</option>
<option value=" Customer Service ">Customer Service</option>
<option value=" Webmaster ">Webmaster </option>
</select>
<br /><br />
Your Full Name: <br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
How can we assist you?
<br />
<textarea name="notes" rows="10" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
</form>






sendemail.php---------->the php script that should send the 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 = 'ToTheLetter Customer Service Request';

$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 protected]', $subject, $message, $from);
?>
 

LouTheDesigner

New Member
php mail functions will sometimes not work with certain e-mail providers. This could be the case here. They won't work with my gmail account.
 

conor

New Member
theres nothing wrong with that code, I ran it on my computer and changed the sending email to my local mailserver. I got the following email:

Code:
 Sunday, March 8, 2009, 7:34 pm [EST] 

Attention:  Sales  

Message: test 

From: Conor Mac Aoidh ([email protected])

Additional Info : IP = 127.0.0.1 

Browser Info: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008121622 Fedora/3.0.5-1.fc10 Firefox/3.0.5 

Referral :

As suggested above this could be to do with the place you are sending the email from. Are you trying this locally? Most mail clients don't accept mail from unknown hosts such as your own computer, They do get through sometimes but not allways.

The solution to this problem is to set up a mail server on your computer so that you can test these things before going live.

Hope that helps.
 

darksoul32

New Member
Your host may not allow scripts like that. I recommend either switching hosts or testing this out. Go to your Cpanel or whatever it is and create a forwarding email adress. Then set the email to that forwarding adress. Something like "[email protected]" and send it to that. That should work. I had to do that before for a contact me script. So basically they send the email to your email adress on your domain and it forwards it to your real email adress.

Alot of hosts dont allow you to send emails from php scripts.
 

emopoops

Banned
there a semi good one im using that is hosted somewhere else i forgot let me check it sends for u and it free an has captcha and other things. always works for me.
oh emailmeform
 
My email send won't allow the message to go through. A box pops up saying "Are you sure you want to send a empty message? It's in a script box that says " add hyperlink, but when I type the link in it still does nothing.
 

conor

New Member
They usualy wont work sending from a local computer to a gmail account because gmail blocks them as an anti-spam measure. They should still work when you upload them to a live server.

A solution around that is to set up a local mail server and send all emails through PHP to that server.
 
Top