Sending information via PHP

Hi, my problem is Im trying to set up a page where you can send your email addy to a destination email addy.
It works fine when I put my own addy as the destination (info@aardesign.co.uk)
But it doesnt work when I test it on other addys.

This my HTML

<!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=iso-8859-1” />
<title>lime_home</title>
<link href=“limestylesheet.css” rel=“stylesheet” type=“text/css” media=“screen” />
</head>

<body>

<div id=“background”>
<div id=“peel”><img src=“grain.png” width=“800” height=“500” border=“0” /></div>

<div id=“fresh”><img src=“fresh.png” alt=“logo” width=“570” height=“150” border=“0”/></div>
<div id=“soon”><img src=“comingsoon.png” width=“500” height=“100” border=“0”/></div>
<div id=“emailtext”>Submit your email to be notified when we go live</div>

<div id=“bar”><img src=“middlebar.png” width=“1000” height=“68” border=“0”/></div>
<div id=“emailsend”>
<form action=“feedback.php” method="post"enctype=“multipart/form-data”>

<input type=“text” name=“comments” size=“50”>
<input type=“submit” class=“submitButton” value=“Submit” />
</p>
</form>
</div>
<div id=“maintext”>Lime4 is a fresh company providing clear thinking and high quality expertise in project management and the development of
sustainable solutions. Whether through project development, production of business cases and feasibilities, or more specifically
related to the blossoming green and environmental sector.</div>
<div id=“limelogo”><img src=“limelogo.png” width=“170” height=“135” border=“0”/></div>
<div id=“address”>Studio B, Derwentside Business Centre, Consett Business Park Consett, DH8 5BP</div>
<div id=“details”>Phone : 01207 693 913 Mobile: 07729 327 323 e-mail: chris@lime4.co.uk</div>
</div>
</body>
</html>

This my PHP it is attached to:

<?php
$comments = $_POST[‘comments’];
$to = “info@echographics.co.uk”;
$re = " New website email feedback";
$msg = $comments;
mail ( $to, $re, $msg );
?>
<!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=iso-8859-1” />
<title>Untitled Document</title>
</head>

<body>
<h1>Thanks for your email address, we will be in touch.<h1>
</body>
</html>

Can anyone help with my problem please?
Thanking you in advance,
Alan.:confused:

PS this the page in question:
http://www.aardesign.co.uk/lime/index.html

you’re not using the mail() function correctly.

It looks okay to me. The parameters are being used correctly.

Are the emails being snagged by your spam filter?

from the manual

When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): “sendmail_from” not set in php.ini or custom “From:” header missing. The From header sets also Return-Path under Windows.

@OP

where is the “From” header set in your code if it’s not set in your php.ini?

also, your message

 
<h1>Thanks for your email address, we will be in touch.<h1>

is being displayed whether the email is successfuly sent or not.

my suggestion is to read up on what mail() returns (in the link I posted) and then display that “Thank you…” message only if the email is sent successfully.

the link shows examples



<?php
$comments = $_POST['comments'];
$to = "info@echographics.co.uk";
$re = " New website email feedback";
$msg = $comments;
mail ( $to, $re, $msg );
?>


i think the problem lies within here.

the following code is correct syntax, you may want to compare.


<?php

$Name = "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\\r\
"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>

How do I use it then?

Im sorry Kalon, I didnt follow your link (Ive just woken up!!)

It works fine when I put my own addy as the destination (info@aardesign.co.uk)

so no, you’re NOT using the mail function incorrectly, which means there’s a default From set in php.ini. You probably want to set one anyway, but that isn’t the solution to your problem.

Why is your form set to multipart, when you’re only passing a text field?

And sanitize your mail. Stick some words around it or something to prevent header injections.

Other than that, are you certain the mail isnt getting caught by junk filters, as was previously mentioned?

I checked my junk folder and there was nothing there.
Perhaps it is something to do with multipart as you mentioned.
Im only getting to grips with PHP and I got the code out of a book and tried to adapt it.:confused:

PS What would I use instead of multipart?

Forms default to “application/x-www-form-urlencoded” when you dont specify an enctype.

Dont want to speak to soon but I didnt specify an enctype and let the default kick in, and Ive put several different addys in the $to and it seems to be working (thanks Star Lion - you’re a star!!).:slight_smile:

The script would throw an error if it were not set in the php.ini file, saying that it should be set in the php.ini file. Of course, it wouldn’t show up if errors were turned off.

that’s why I asked the op the question.