Jump to content

sending email via PHP


lordbob

Recommended Posts

I am trying to make a 'forgot password' tool on my website, basically the person fills out an HTML form which is then sent to a php file called forgot.PHP

(they send $Email to the PHP file via GET method)

this is my code for forgot.php:

[code]<?
//-------------------------------------------Connect to Database:
//set the variables as required
$dbhost = "fdb1.awardspace.com";
$dbuser = "rocketeermus_db1";
$dbpass = "******";
$dbname = "rocketeermus_db1";

//do not edit this, it connects the script
$members = mysql_connect($dbhost,$dbuser,$dbpass);//line10

mysql_select_db($dbname) or die(mysql_error());

//------------------------------------------------------------------Send Mail Bit

$sql="SELECT Password, Username FROM Members WHERE Email='$Email'";
$result=mysql_query($sql);//line20

$count=mysql_num_rows($result);
if($count==1){

$rows=mysql_fetch_array($result);
// keep password in $your_password
$your_password=$rows['Password'];
$your_username=$rows['Username'];

$subject = "Password Request";//line30
$body = "Your password request has been processed!\n\nUsername: $your_username\nPassword: $your_password";

if (mail($Email, $subject, $body)) {
  echo"<p>Message successfully sent!</p>";
} else {
  echo"<p>Message delivery failed...</p>";
}
}
else
{
echo"<p>Your email address was not found on our database, you must register first!</p>";
}
?>[/code]

does anyone know why it isnt sending the email?
thanks ~
Link to comment
Share on other sites

HELP YOURSELF.

You need to use the additional headers as outlined here. http://us3.php.net/manual/en/function.mail.php
Specifically MIME type and these:
$headers = 'From: webmaster@example.com' . "\r\n" .
  'Reply-To: webmaster@example.com' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

Read the documentation and TRY to understand.
Link to comment
Share on other sites

are your ini settings correct ?
this works for me (with my details)
[code]
$subject = 'title string';
$body = 'email string you want to send';
$email = 'info@example.com';//working mailbox from your domain
$header = "From: $email";


ini_set("SMTP", "ASK YOUR PROVIDER"); //use for online version
ini_set("smtp_port", "25");
mail($to, $subject, $body, $header);
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.