PHP mailing

Status
Not open for further replies.

tonymcv1

New Member
Messages
7
Reaction score
0
Points
0
Hi. I dont know if this is the correct way to address my problem so apologies if I'm wrong. My site has a feedback form which uses PHP to send the info to my email address. I've tried using the form but no info comes across.
Does my free hosting suport PHP and/or do I have to enable something else to use it.
Here is my code if it will help.

Thanks in advance,

Tony

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
<title>Email Form</title>
</head>

<body>
<?php
$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comments=addslashes($_POST['message']);

// you can specify which email you want your contact form to be emailed to here

$toemail = "tonymcv1@gmal.com";
$subject = "From EcoStyleStudio.com";

$headers = "MIME-Version: 1.0\n"
."From: \"".$name."\" <".$email.">\n"
."Content-type: text/html; charset=iso-8859-1\n";

$body = "Name: ".$name."<br>\n"
."Email: ".$email."<br>\n"
."Comments:<br>\n"
.$comments;

if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
{
echo "That is not a valid email address. Please return to the"
." previous page and try again.";
exit;
}

mail($toemail, $subject, $body, $headers);
echo "Thanks for submitting your comments";
?>
</body>
</html>
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
The from address must be one actually on your x10hosting account, or it will be blocked because of it forging headers. In your case, setting the from address to a gmail address is your problem - gmail isn't an x10hosted service, and to put it lightly they -really- hate it when people forge headers to make it seem like it came from them when it didn't. There's two options - use Google Apps and SMTP to send the emails through the google apps service themselves, or change the from address to one on your hosting account.

There may be other problems with it sending, but that's the first one I'm seeing - our outbound email system won't even let this one get outside the x10hosting network because it's forging a header.
 

tonymcv1

New Member
Messages
7
Reaction score
0
Points
0
Hi. Thanks for reply.
I've tried changing my code to the following but I'm still having no joy with it going through:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META HTTP-EQUIV="refresh" content="0;URL=thankyou.html">
<title>Email Form</title>
</head>


<body>
<?php
$name=addslashes($_POST['name']);
$email=addslashes($_POST['email']);
$comments=addslashes($_POST['message']);


// you can specify which email you want your contact form to be emailed to here


$toemail = "tonymcv@tonymcv.x10.mx";
$subject = "Tonys Site";


$headers = "MIME-Version: 1.0\n"
."From: \"".$name."\" <".$email.">\n"
."Content-type: text/html; charset=iso-8859-1\n";


$body = "Name: ".$name."<br>\n"
."Email: ".$email."<br>\n"
."Comments:<br>\n"
.$comments;


if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
{
echo "That is not a valid email address. Please return to the"
." previous page and try again.";
exit;
}


mail($toemail, $subject, $body, $headers);
echo "Thanks for submitting your comments";
?>
</body>
</html>
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
What are you passing as the from email here: $headers = "MIME-Version: 1.0\n"
."From: \"".$name."\" <".$email.">\n"

That's the from email address I meant to refer to; if that from is -not- an x10hosting based email the mailing system will deny it. If this is for a contact form, you might do better having the From and To address both be one from your hosting account, then have the body say "This is feedback sent from <actual email address here>" - this won't anger the mailing system but it'll still tell you the email address entered.
 
Status
Not open for further replies.
Top