Page 1 of 1

Problem with Email Sending

Posted: Wed Feb 08, 2012 11:05 am
by Madiha
I have the following code, And it is not sending Email. Infact it is only displaying the interface. When i click on button it does nthng. I am working with Wamp Server and dreamweaver. Please if any body could help.

Code: Select all

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EmailForm</title>
<style type="text/css">
body {
	margin-left: 10px;
	margin-top: 10px;
	background-color: #FFF;
}
body,td,th {
	color: #666;
}
</style>
<?PHP
if(isset($_POST['Submit1']))
{$Email=$_POST['Email'];
$Comments=$_POST['Comments'];

$headers = 'MIME-Version: 1.0' . "\r\n";
 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 $headers .= ‘From: madeeha.rehman5@gmail.com' . "\r\n";

if(mail('madeeha.rehman5@gmail.com','Hello',$Comments,$headers))
{echo("Your Email is sent successfully");
}
Else
{echo("Email Sending Failed");}
	}
?>
</head>

<body text="#999999">
<form id="EmailForm" name="EmailForm" method="POST" action="file:///E|/Sites/EmailForm.php">
<table width="450px">
<tr><td valign="top">
<label>First Name *</label></td>
<td valign="top">
<input name="FName" type="text" size="30px" /></td></tr>
<tr><td valign="top">
<label>Last Name *</label></td><td valign="top">
<input name="LName" type="text" size="30px"/>
</td></tr>
<tr><td valign="top">
<label>Email Address *</label></td><td valign="top">
<input name="Email" type="text" size="30px"/></td></tr>
<tr><td valign="top">
<label>Comments *</label></td><td valign="top">
<textarea name="Comments" cols="25" rows="5"></textarea></td></tr>
<tr><td colspan="2" style="text-align:center">
<input name="Submit1" type="Submit" value="Submit" style="color:#000" /></td></tr>
</table>
</form>


</body>
</html>

Re: Problem with Email Sending

Posted: Wed Feb 08, 2012 3:27 pm
by social_experiment

Code: Select all

$headers .= 'From: madeeha.rehman5@gmail.com' . "\r\n";
The code seems to have a syntax error; you use a ` instead of a ' in the above line

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 1:27 am
by suresh010
<?php include('includes/connection.php');

if(isset($_POST['Submit']))
{

$comments=$_POST['comments'];

$to = $_POST['email'];

$from='yourmailname@gmail.com';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: <'.$from.'>' . "\r\n";


$subject = "Hi!";
$body = $_POST['comments'];
mail($to, $subject, $body, $headers);

?>

<script language="javascript" type="text/javascript">
{
alert("your mail sent successfully");
document.location='yourpage.php';
}
</script>

<?php

}
?>

check for the above code it will work fine

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 1:49 am
by suresh010
<?PHP
if(isset($_POST['Submit1']))
{$Email=$_POST['Email'];
$Comments=$_POST['Comments'];

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: madeeha.rehman5@gmail.com' . "\r\n";

if(mail('sureshaaluri@gmail.com','Hello',$Comments,$headers))
{echo("Your Email is sent successfully");
}
Else
{echo("Email Sending Failed");}
}
?>
<!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=utf-8" />
<title>EmailForm</title>
<style type="text/css">
body {
margin-left: 10px;
margin-top: 10px;
background-color: #FFF;
}
body,td,th {
color: #666;
}
</style>
</head>

<body text="#999999">
<form id="EmailForm" name="EmailForm" method="POST" action="#">
<table width="450px">
<tr><td valign="top">
<label>First Name *</label></td>
<td valign="top">
<input name="FName" type="text" size="30px" /></td></tr>
<tr><td valign="top">
<label>Last Name *</label></td><td valign="top">
<input name="LName" type="text" size="30px"/>
</td></tr>
<tr><td valign="top">
<label>Email Address *</label></td><td valign="top">
<input name="Email" type="text" size="30px"/></td></tr>
<tr><td valign="top">
<label>Comments *</label></td><td valign="top">
<textarea name="Comments" cols="25" rows="5"></textarea></td></tr>
<tr><td colspan="2" style="text-align:center">
<input name="Submit1" type="submit" value="Submit" style="color:#000" /></td></tr>
</table>
</form>
</body>
</html>


i checked ur code and modified it.. plz replace it with ur excisting code or you can replace the my previous post also

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 4:24 am
by Madiha
Sir, Its doing nthng. Means when i click on Submit, All the fields are cleared and No email is sent.

In the php.ini file i have following configuration.
SMTP=localhost
Sentmail_From=madeeha.rehman5@gmail.com..
I save the php.ini file after making these chnges.. But when i Open phpinfo() in the local host.. SMTP =localhost as usual..
And in the Sentmail_From: no value is written..

If there is a problem with my SMTP settings. How to change these. Please could you help me more.

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 4:26 am
by Madiha
Sir, Its doing nthng. Means when i click on Submit, All the fields are cleared and No email is sent.

In the php.ini file i have following configuration.
SMTP=localhost
Sentmail_From=madeeha.rehman5@gmail.com..
I save the php.ini file after making these chnges.. But when i Open phpinfo() in the local host.. SMTP =localhost as usual..
And in the Sentmail_From: no value is written..

If there is a problem with my SMTP settings. How to change these. Please could you help me more.

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 4:49 am
by suresh010
hi upload the code to server ... in locahost it wont provide the permissions to send the mail.. but once you upload to server it can provide the permissions to send the mail.. i tested the same code in online ( after uploading to server ) its working fine.. just you upload the code to server and test it and let me know the status

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 5:12 am
by social_experiment
@Madiha Do you want to use your localhost to send email ?

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 6:24 am
by Madiha
@Suresh010..
U really helped me. Thank you

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 6:25 am
by Madiha
@Suresh010..
U really helped me. Thank you

Re: Problem with Email Sending

Posted: Thu Feb 09, 2012 6:43 am
by suresh010
its ok my friend ...............