PDA

View Full Version : PHP mailto help


vkw91
04-20-2006, 04:14 PM
Hi, Im using Fasthosts and i have a php on my website for a mail to:

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd = 'vicky@smartprofile.co.uk';

// Where to redirect after form is processed.
$url = 'http://www.wxmtiles.co.uk/thanks.htm';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

But this does not work and they told me to do this

"Use the PHP mail function and set the mail from using the following line of code - replacing email@mydomain with the correct domain name.

ini_set("sendmail_from", " email@mydomain ");

But were do I put that line of code??!?

Creative Insanity
04-20-2006, 06:07 PM
That script does work, trust me I have used it many times.
Place a form in your document and have as many NAMED fields as you like and then make the forms action to that script and that is it.
Not rocket science.

vkw91
04-20-2006, 06:23 PM
I know how to use it, The question i'm asking is that because i'm using fasthosts, it has told me to do the following:

Use the PHP mail function and set the mail from using the following line of code - replacing email@mydomain with the correct domain name.

ini_set("sendmail_from", " email@mydomain ");


But where do i put the ini_set("sendmail_from", " email@mydomain "); in the code above??

because if i don't, the form won't work!

vkw91
04-20-2006, 06:47 PM
Ok, solved now!

If anyone else has got this problem, go to:

http://www.dbmasters.net/forum.php?id=21&tid=148