mail(); error

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
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

mail(); error

Post by qads »

hi,
i am useing

Code: Select all

mail("$email","$getїsite_name] - Welcome","$body","From:$getїemail]";
to send emails, all the values are from either database or a form, but i get this error:

Code: Select all

Warning: Failed to Receive in c:\apache\htdocs\trial\phpauth\tmploxjs2huja.php on line 112
i don't have a file called tmploxjs2huja :?

i have searched php.net but have't found any thing, please help.

also what is the best way to send emails, both on window and *nix?
i need something that works on both with out problems.

thanks for your help
p.s. php version is PHP is 4.2.3
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Could you post a link to the .phps file of your .php? Or just give the code on here?
Image Image
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well here is all of it, you should be looking at the php code which is at the bottem

Code: Select all

<?php include("admin/inc/db.inc.php");
$date = date("d/m/Y");
$siteinfo = mysql_query("SELECT `url`,`site_name`,`email` FROM `site_info`");
$get = mysql_fetch_array($siteinfo);
?>
<title><?php print("$get&#1111;site_name]"); ?></title>
<div align="center">
  <p><font size="7" face="Tahoma"><b><i>Join</i></b></font></p>
  <p>&nbsp;</p>
</div>
<center>

<form name='form1' method='post' action=''>
  <table width='262' border='0' cellpadding='0' cellspacing='0'>
    <tr> 
      <td width='132' height='28' valign='middle'> 
        <div align='right'><font size='2'><b><font face='Tahoma'> Username:</font></b></font></div>
      </td>
      <td width='130' valign='top'> 
        <input type='text' name='username'>
      </td>
    </tr>
    <tr> 
      <td valign='middle' height='28'> 
        <div align='right'><font face='Tahoma' size='2'><b> Password:</b></font></div>
      </td>
      <td valign='middle'><font size="2" face="Tahoma" color="#FF0000">Will be 
        sent to in a email
        <input type="hidden" name="join">
        </font></td>
    </tr>
    <tr> 
      <td valign='middle' height='28'> 
        <div align='right'><b><font size='2' face='Tahoma'> Email:</font></b></div>
      </td>
      <td valign='top'> 
        <input type='text' name='email'>
      </td>
    </tr>
    <tr> 
      <td height="23" valign="middle"> 
        <div align="right"><b><font size="2" face="Tahoma">Join Mailing List?</font></b></div>
      </td>
      <td valign="top"> 
        <input type="radio" name="mailing" value="1">
        <font size="2" face="Tahoma"><b>Yes</b></font><br>
        <input type="radio" name="mailing" value="0">
        <b><font size="2" face="Tahoma">No</font> </b></td>
    </tr>
  </table>
  <input type='submit' value=' OK! ' name='submit'>
</form>
<?php 
if(IsSet($join))
&#123;
function random_char($string)
&#123;
$length = strlen($string);
$position = mt_rand(0, $length - 1);
return($string&#1111;$position]);
&#125;
function random_string ($charset_string, $length)
&#123;
$return_string = random_char($charset_string);
for ($x = 1; $x < $length; $x++)
$return_string .= random_char($charset_string);
return($return_string);
&#125; 
mt_srand((double)microtime() * 1000000);
$charset = "abcdefghijklmnopqrstuvwxyz1234567890ABCDE_FGHIJKLMNOPQRSTWXYZ";
$charset1 = "abcdefghijklmnopqrstuvwxyz1234567890ABCDE_FGHIJKLMNOPQRSTWXYZ";
$password = random_string($charset, 6);
$login_code = random_string($charset1, 6);
$Epassword = MD5($password);
if(Empty($username))
&#123;
print("Please Fill in all the fields<br>");
exit;
&#125;
if(Empty($email))
&#123;
print("Please Fill in all the fields<br>");
exit;
&#125;
else
&#123;
$check = mysql_query("SELECT `username` FROM `users` WHERE 1 AND `username` LIKE '$username'");
$records = mysql_num_rows($check);
if($records > 0)
&#123;
print("$username is already in use, please choose a differnet username...");
&#125;
else
&#123;
$query1 = "INSERT INTO `users` (`username`, `password`, `email`, `mailing_list`, `date`, `last_login`, `pass`, `login_code`) VALUES ('$username', '$Epassword', '$email', '$mailing', '$date', '00/00/00', '$password', '$login_code')";
$in = mysql_query($query1) or die ("Unable to Insert new Member...plase contact the webmaster...");
print("Welcome to $get&#1111;site_name], Please check your email inbox for your password and other information.<br><center><br><a href="http://www.qadsscripts.t2u.com"><font size="2">Script From QadsScripts</font></a>");
$body = "
Welcome to $get&#1111;site_name],
Here is your account information at $get&#1111;site_name]:

Username: $username
Password: $password

To login please go to: $get&#1111;url]

**********Please Note***************
This is not spam mail, some one asked us to send this information on this email address.
**********Thank You************
*******Script From Qadsscripts.t2u.com*********";

mail("$email","$get&#1111;site_name] - Welcome","$body","From:$get&#1111;email]");
&#125;
&#125;
&#125;
?>
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

bah....no one knows :?

well..here is what's wrong:
in php.ini i did't set the smtp host, as soon as fixed that, it started working!
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

lol, check your configuration before the code :lol:
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

lol, the problem was that it was't my server, someone else owns it, so i had no way of knowing that, so just for the heck of it, i removed the smtp line to see if i will get the same error...and i did :P
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

Is it a shared hosting? Or it's just your friend's? I still haven't manage to to set my SMTP server on my server :lol:
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

no, it was one of the users from my site :?
Post Reply