Email sending problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tanvirtonu
Forum Commoner
Posts: 35
Joined: Wed Oct 17, 2007 9:15 am

Email sending problem

Post by tanvirtonu »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I made a simple Html form which takes user mail info and message and send it.I [s]hav[/s] [size=150][color=green]have[/color][/size] made another php script for the  mail to be sent. My code is given below-

Code: Select all

<html>
<head>
<title>E-mail Sending Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<?php
echo "Thank You <b>$_POST[name]</b> for ur message";
echo "<p>Your mail address is <p>$_POST[email] </p>";
echo "<p>Your message was <p> $_POST[msg] </p>";
//building the message.
"$msg="Name: $_POST[name]\n";
$msg.="E-mail $_POST[email]\n";
$msg.="Message $_POST[msg]\n";
//set up mail
$subject="Tanvir's Form Submission Results";
$recepeint="bhonest_4ever@yahoo.com";
$mailheader="From: Tanvirs House <tanvirtonu@yahoo.com>\n";
$mailheader.="Reply to $_POST[email]";
//send the mai
 
mail($recepeint,$subject,$msg,$mailheader);



?>
</body>
</html>
my HTML form code is-

Code: Select all

<html>
<head>
<title>EmailFORM</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="Email.php" method="post">
<p>Your Name</p>
<input type="text" name="name">
<p>Mail Address</p>
<input type="text" name="email">
<p>Message</p>
<textarea name="msg" cols="30" rows="10"></textarea>
<p>
<input type="submit" value="Send" >
</p>

</form>
</body>
</html>
But when I press send button, I cant send the mail, Is says-

" Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\xampp\htdocs\Email.php on line 24 "

WHAT IS [s]D[/s] the PROBLEM.How can I know which smtp port my ISP is using.In php.ini file the port value is 25.
What [s]shud[/s] should I do.[s]pls[/s] please help.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]11.[/b] Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.[/quote]
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Well SMTP always uses port 25. What are your "SMTP" and "smtp_port" setting in php.ini? That is the problem being reported.
(#10850)
rturner
Forum Newbie
Posts: 24
Joined: Sun Nov 04, 2007 1:39 pm

call you isp

Post by rturner »

if your webhost is not configured properly you may receive this sort of message. Netfirms is an example of one that struggles with php mail but not perl. Contact their support dept.

I would suggest that you run the variables through htmlspecialchars to filter malicious input.
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

change your code

Post by webspider »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi tanvirtonu

i notice problem in the syntax of your code  . change following portion of your code

Code: Select all

//building the message.
"$msg="Name: $_POST[name]\n";
$msg.="E-mail $_POST[email]\n";
$msg.="Message $_POST[msg]\n";
would be

Code: Select all

//building the message.
$msg="Name: ".$_POST[name]."\n";
$msg.="E-mail ".$_POST[email]."\n";
$msg.="Message ".$_POST[msg]."\n";

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply