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
https://forums.phpfreaks.com/topic/34641-sending-email-via-php/
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: [email protected]' . "\r\n" .
  'Reply-To: [email protected]' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

Read the documentation and TRY to understand.
Link to comment
https://forums.phpfreaks.com/topic/34641-sending-email-via-php/#findComment-163260
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 = '[email protected]';//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
https://forums.phpfreaks.com/topic/34641-sending-email-via-php/#findComment-163331
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.