Problem with Email Sending

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
Madiha
Forum Newbie
Posts: 7
Joined: Wed Feb 08, 2012 10:52 am

Problem with Email Sending

Post 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>
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Problem with Email Sending

Post 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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
suresh010
Forum Newbie
Posts: 6
Joined: Thu Feb 09, 2012 12:54 am

Re: Problem with Email Sending

Post 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
suresh010
Forum Newbie
Posts: 6
Joined: Thu Feb 09, 2012 12:54 am

Re: Problem with Email Sending

Post 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
Madiha
Forum Newbie
Posts: 7
Joined: Wed Feb 08, 2012 10:52 am

Re: Problem with Email Sending

Post 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.
Madiha
Forum Newbie
Posts: 7
Joined: Wed Feb 08, 2012 10:52 am

Re: Problem with Email Sending

Post 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.
suresh010
Forum Newbie
Posts: 6
Joined: Thu Feb 09, 2012 12:54 am

Re: Problem with Email Sending

Post 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
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Problem with Email Sending

Post by social_experiment »

@Madiha Do you want to use your localhost to send email ?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Madiha
Forum Newbie
Posts: 7
Joined: Wed Feb 08, 2012 10:52 am

Re: Problem with Email Sending

Post by Madiha »

@Suresh010..
U really helped me. Thank you
Madiha
Forum Newbie
Posts: 7
Joined: Wed Feb 08, 2012 10:52 am

Re: Problem with Email Sending

Post by Madiha »

@Suresh010..
U really helped me. Thank you
suresh010
Forum Newbie
Posts: 6
Joined: Thu Feb 09, 2012 12:54 am

Re: Problem with Email Sending

Post by suresh010 »

its ok my friend ...............
Post Reply