Menu
I’m trying to adjust my [Mail Function] properties in php.ini . For sendmail_from entry I put “[i]sendmail_from = [email][email protected]
This is in my php.ini file.[/QUOTE]
Is the above necessary if I am using the contact form on a website? Or is it only necessary if I plan on running it on my local server?[/QUOTE]
In addition to the above...
To my understanding, it is never "necessary". It is only [u]useful[/u] if you plan on using PHP's built-in mail handling abilities to send mail from your server.[/QUOTE]
Perhaps I should post my script in case something's wrong with it?[/QUOTE]
[code=html]
<body bgcolor="#ffffff" text="#666666">
<font face="verdana" size="1">
<form method="post" action="sendmail.php">
Your Name:<br>
<input type="text" name="name" style="border: 1px solid #cccccc; background-color: #ffffff;"><br><br>
Your E-mail Address:<br>
<input type="text" name="email" style="border: 1px solid #cccccc; background-color: #ffffff;"><br><br>
Subject:<br>
<input type="text" name="subject" style="border: 1px solid #cccccc; background-color: #ffffff;"><br><br>
Message:<br>
<textarea name="message" cols="40" rows="10" style="border: 1px solid #cccccc; background-color: #ffffff;"></textarea>
<br><br>
<input type="submit" value="send" style="border: 1px solid #cccccc; background-color: #ffffff;">
</form>
</font>
[/code]
[code=php]
<?php
$name = stripslashes($name);
$email = stripslashes($email);
$subject = stripslashes($subject);
$message = stripslashes($message);
mail('[email protected]',$subject,$content,"From: $name <$email>");
header("location:/thankyou.html");
?>
[/code]
[code=php]<?
if (mail('[email protected]',$subject,$content,"From: {$name} <{$email}>")):
header("location:/thankyou.html");
else:
header("location:/mailerror.html");
endif;
?>[/code]
The script is still not working at the moment though.[/QUOTE]
I recently had to spend a lot of time finetuning a function for mail() which would work properly on both Linux and Win32 server. Here's the wrapper function, which should solve all (or most) of the common problems that beginners run into:
[code=php]function send_mail($myname, $myemail, $contactname, $contactemail, $subject, $message) {
$headers .= "MIME-Version: 1.0n";
$headers .= "Content-type: text/plain; charset=iso-8859-1n";
$headers .= "X-Priority: 1n";
$headers .= "X-MSMail-Priority: Highn";
$headers .= "X-Mailer: phpn";
$headers .= "From: "".$myname."" <".$myemail.">n";
return(mail(""".$contactname."" <".$contactemail.">", $subject, $message, $headers));
}[/code]
This has been tested with both Linux (qmail) and Win32 (ezmts) mail servers, and worked perfectly well. Note that the two headers "X-Priority" and "X-MSMail-Priority", can be left out - but they will help overcome some of the more aggressive spam filtering systems (hotmail, yahoo mail, ...) and ensures your mail is delivered.
Also note that you should use n for new lines in the body of your message - not r or rn ... these don't work on all mail servers, but apparently n does.
Finally, here's an example of using the function, sending an email from "the company" to "the customer":
[code=php]if (send_mail("Company", "[email protected]", "Customer", "[email protected]", "This is a test", "This is a testnOne two three fournBlah blah blahnThis is a test!")) {
print "SENT!";
} else {
print "FAILED!";
}[/code]
[/quote]
I don't need the form to send mail to others, I need it so that visitors can send me an e-mail directly through the website. Similar to this[URL=http://www.lushbags.com]website[/URL] here. From what I understand I don't need to do anything to the php.ini file if it's hosted on a website, right? Jona has a contact form also on his[URL=www.cmmwebdesign.com/v3]website[/URL] . That's what I have in mind, and I tried doing, but it did not send me mail.[/QUOTE]
I'm trying to adjust my [Mail Function] properties in php.ini .[/QUOTE]You need to give a run down of exactly what you want. Also where is it being hosted, local or ISP? Linux or windows? etc?
[code=php]
<?php
$to = 'your email here';
mail ($to, $_POST['subject'], $_POST['message'], "From:$_POST['email']");
?>
[/code]
Jay, you are talking double dutch to me! [/QUOTE]
but I wasn't receiving the e-mail. [/QUOTE]
[CODE]<?php
$from = "From: " . $from;
mail($to, $subject, $body, $from);
?>[/CODE]
[CODE]<html>
<body>
<form action='mail.php' method='post'>
To:
<input type='text' name='to' />
<br />
From:
<input type='text' name='from' />
<br />
Subject:
<input type='text' name='subject' />
<br />
Message: <br />
<textarea cols="50" rows="15" name="body">
</textarea>
<input type='submit' value='Send' name='submit' />
</form>
</body>
</html>[/CODE]
Originally posted by [B]webgovernor[/B]
If that doesn't work, then it's a server problem,
bit it should deffinetly work![/QUOTE]
If that doesn't work, then it's a server problem[/QUOTE]
the savior says, if this code does not work in your server, change your hosting. LOLS, ? , just kidding. He told me that the problem is not in the code but in the server. The server disable the mail() function. so thats why we dont recieve emails during testing of the form.[/QUOTE]
[code=php]<?php
$from = "From: " . $_POST['from'];
mail($_POST['to'], $_POST['subject'], $_POST['body'], $from);
?>[/code]
With [b]register_globals[/b] set off, the following should work[/QUOTE]
However, I'm [u][i]very[/i][/u] happy that we all finally got you going. Cheers. ?[/QUOTE]
where can i find the [I][B]register_globals[/B][/I][/QUOTE]
[code=php]<?php
phpinfo();
?>[/code]
i tried the code and it didnt work to me. so im hopin again for another savior.
? ? , i still dont have the clue. where can i find the [I][B]register_globals[/B][/I], i dont have a php.ini coz' my site is hosted into a server not in my local machine.
Congrats to JayM. u've finally solve your problem. but me not... poor guy..[/QUOTE]
Edit: If you do not care what scripting language to use for the form, I can write you a form using ASP. I know it works because I have written one for a client before.[/QUOTE]
I will not stop until I solve your problem as well [/QUOTE]
[CODE]<?php
phpinfo();
?> [/CODE]
[I]one thing, do i have to upload the page contains that code in the server which my site is hosted or in my local machine?[/I][/QUOTE]
[code=php]
<?php
error_reporting(E_ALL);
if (mail ('[email protected]', 'Subject: This is a test', 'Body: Testing, 1, 2, 3')){
print ('Mail sent');
}else{
print ('Mail not sent');
}
?>
[/code]
ISP (Internet Service Provider). If you are not hosting locally you must be using a server provided by an Internet Service Provider. This is the organization you need to take up your problem with. Obviously I don't mean the ISP that provides your internet connection unless it is one and the same.[/QUOTE]
[B]Message from the support[/B]
sendmail is working on the server make sure you use
Path to : sendmail /usr/sbin/sendmail [/QUOTE]
0.1.9 — BETA 5.5