10uRrr Posted July 9, 2006 Share Posted July 9, 2006 hi everybody;I have a question, I want to send an e-mail by php, the is working but not send I could not find my error if you, tell answer me pls..mail.htm<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>mail</title></head><form method="post" actionfiltered="sendmail.php"> <td>To:<input name="email" type="text" /></br></br></td> <!-- Sender: <input name="email" type="text" /></br></br> --> <td> Subject: </br> <textarea name="subject" cols="15" rows="2"> </textarea></br></td> <td> Message: </br> <textarea name="message" rows="15" cols="40"> </textarea><br /></td> <input type="submit" /> </form></html>sendmail.php<html><head><title>senmail</title></head><? $to = $_POST['email']; // $sender = $_POST['sender']; $subject = $_POST['subject']; $message = $_POST['message'] ; // $headers = "From: localhost\n"; //ini_set("SMTP", "localhost"); @mail( "$to" , "$subject" , "$message"); echo "finished!"; ?></html>where is the error?? Quote Link to comment https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/ Share on other sites More sharing options...
zq29 Posted July 9, 2006 Share Posted July 9, 2006 Maybe you should try removing the @ symbol from the front of your call to the mail() function. Quote Link to comment https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55058 Share on other sites More sharing options...
kenrbnsn Posted July 9, 2006 Share Posted July 9, 2006 What type of machine are is your server? If it is a local windows box you need to set up an smtp mailer address. Also you really should include a "From:" header and you don't need the double quotes around the variable names in the mail() function.[code]<?php$to = $_POST['email'];$subject = $_POST['subject'];$message = $_POST['message'] ;$headers = "From: youremail@address.here\n";mail($to,$subject,$message,$headers);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55082 Share on other sites More sharing options...
redarrow Posted July 9, 2006 Share Posted July 9, 2006 An example of the mail function when the mail is setup on your php.ini ok.$to = 'bob@barnyard.com';$subject = 'Wakeup bob!';$message = '<b>yo</b>, whassup?';$headers = "From: server@barnyard.com\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n";// Sendmail($to, $subject, $message, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55084 Share on other sites More sharing options...
hsncool Posted July 9, 2006 Share Posted July 9, 2006 you have errors all over that thingg!!!im going to try and see how many i can fynd, hehe!!okies, [b]mail.htm[/b]no body tags!also, why are u using <!-- --> 's ???use [b]action="sendmail.php"[/b][b]sendmail.php[/b]if you do use the sender part of ur form, and name it sender..., u can doo ur code like this, and it should work...[code]<html><head><title>[b]sendmail[/b]</title></head>[b]<body>[/b]<?$to = $_POST['email'];$sender = $_POST['sender'];$subject = $_POST['subject'];$message = $_POST['message'] ;$email_to = $sender . "<" . $to . ">"mail($email_to,$subject,$message,"From:my@email.com\n"); echo "finished!"; ?>[b]</body>[/b]</html>[/code]shud work, tell me if dusnt Quote Link to comment https://forums.phpfreaks.com/topic/14082-send-e-mail-by-php/#findComment-55237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.