Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
PHP mail() function. Please help!
Old 10-20-2007, 10:24 PM PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
Having a lot of trouble with my script. I am running a paid to click site and I am trying to contact my members. Unfortunately, I get this error:

Warning: mail(): Bad parameters to mail() function, mail not sent. in /control/mail.php on line 42

That message shows up 6 times.

Any help is greatly appreciated. Thank you!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-20-2007, 10:26 PM Re: PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
The reason it occurs 6 times is because that is how many people it is trying to send it to - at least I figured that out!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
Old 10-21-2007, 02:11 AM Re: PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
Does anybody know why this would happen?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
Old 10-21-2007, 05:09 AM Re: PHP mail() function. Please help!
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
It would have because you sent bad parameters to the mail() function. If you want a more definitive answer, you have to give us something to work with, maybe some of the code?
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-21-2007, 10:42 AM Re: PHP mail() function. Please help!
rogem002's Avatar
PHP Chap

Posts: 843
Name: Mike
Location: United Kingdom
Trades: 0
Most likely you have one of the following:
1. Incorrect parameters
2. Too many parameters
3. Too few parameters

Can you send us the code your using?
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Old 10-21-2007, 11:49 AM Re: PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
Thanks all! Going to be gone for most of the day but I will check this later tonight. Also, I know next to nothing about script, but I have heard that this is horribly written (I got it from someone else). Thanks again in advance.

From my understanding, this is line42 which is having the problems: (complete code listed below)
PHP Code:
mail($a1[0], $subject$message$mailheaders); 
PHP Code:
<?

include('includes/header.php');
include(
'../includes/data_conn.php');

if(isset(
$submit))
{
    if(empty(
$who))
    {
    echo 
"<center><br><br><br> You did not choose the emails recipient.<br> Go <a class=TN href=mail.php> back </a> and make your choice. </center>";
    exit;
    }
    if(empty(
$message))
    {
    echo 
"<center><br><br><br> You are trying to send blank email. <br> Go <a class=TN href=mail.php> back </a> and write some text. </center>";
    exit;
    }
     if(
$_POST[who] == 'members')
     {
    
$q1 "select email from users ";
    
$r1 mysql_query($q1) or die(mysql_error());
     }
     elseif(
$_POST[who] == 'advertisers')
     {
    
$q1 "select email from newl ";
    
$r1 mysql_query($q1) or die(mysql_error());
     }

    while(
$a1 mysql_fetch_array($r1))
    {
    
    
$get_general mysql_query("SELECT * FROM main");
                
$grow mysql_fetch_array($get_general);
                
$g_title $grow[title];
                
$g_baseurl $grow[baseurl];
                
$g_aemail $grow[adminemail];
                
$g_newsemail $grow[newsemail];
                
        
$mailheaders "From: " .$g_newsemail"\n\n";
        
$mailheaders .= "Reply-To: " .$g_newsemail"\n"
        
$mailheaders .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\n";
    
mail($a1[0], $subject$message$mailheaders);
    }
    echo 
"<center><br><br><br>The mail was sent successfully. </center>";
    unset(
$who);
    exit;
}
?> 
<div align="center"><br>
  <strong><font size="2" face="Arial, Helvetica, sans-serif">Email Members</font></strong><br>
</div>
<form action=<?=$PHP_SELF?> method=post>
  <table align=center width=550>
    <tr> 
      <td><font size="2" face="Arial, Helvetica, sans-serif"> Send emails to all: 
        </font></td>
      <td> <select name=who>
          <option value="">Select </option>
          <option value="members">Members </option>
          <option value="advertisers">Advertisers </option>
        </select> </td>
    </tr>
    <tr> 
      <td><font size="2" face="Arial, Helvetica, sans-serif">Subject: </font></td>
      <td><input type=text name=subject></td>
    </tr>
    <tr> 
      <td valign=top><font size="2" face="Arial, Helvetica, sans-serif">Message: 
        </font></td>
      <td><textarea rows=6 cols=45 name=message></textarea></td>
    </tr>
    <tr> 
      <td colspan=2 align=center> <input type=submit name=submit value=Send> </td>
    </tr>
  </table>
</form>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
Old 10-21-2007, 12:42 PM Re: PHP mail() function. Please help!
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
Apart form the fact that that isn't well coded in terms of readability, it seems your main problem is that you have declared $subject. Or message, at least I can't see where you have.

PHP Code:
mail($a1[0], $_POST[subject], $_POST[message], $mailheaders); 
Having said that, the line if(empty($message)) seems to be working fine, even though $message hasn't been declared. Oh well.

p.s. You need an apostrophe in email(')s.<br> won't validate also. You want <br /> actually, most of the above won't validate. Oh and <center> is deprecated.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-21-2007, 02:23 PM Re: PHP mail() function. Please help!
Super Talker

Posts: 134
Trades: 0
from php.net : Multiple extra headers should be separated with a CRLF (\r\n).

in this case: $mailheaders ---> change \n\n and \n to \r\n
__________________

Please login or register to view this content. Registration is FREE

Check out the Facebook Clone build with Jcow SNS at
Please login or register to view this content. Registration is FREE
, it is free and it always will be
Falcone is offline
Reply With Quote
View Public Profile
 
Old 10-21-2007, 09:23 PM Re: PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
Thanks for the help guys, I'll take a look at all of this and let you know!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
Old 10-21-2007, 09:42 PM Re: PHP mail() function. Please help!
Novice Talker

Posts: 10
Trades: 0
Those changes worked! I have a few other problems, but they are not directly related to the mail() function. Would you guys be interested in offering input with those as well? If not I can make a new post.

Thanks again!!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
onlinecashflow is offline
Reply With Quote
View Public Profile
 
Old 10-23-2007, 07:43 AM Re: PHP mail() function. Please help!
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
Try me. I'm always interested in these things, especially when there's Talkupation in it!

Thanks btw for the last lot.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Reply     « Reply to PHP mail() function. Please help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.37499 seconds with 12 queries