Mail() works in 1 script, but not in this one...

Status
Not open for further replies.

cybert97

New Member
Messages
9
Reaction score
0
Points
0
Mail() isn't working for some odd reason, it works in another one(registration), just not this one(password reset).
My script:
PHP:
//Allow html in email            $headers = "From: manseld5@gmail.com"."\r\n";            $headers .= "Content-type: text/html"."\r\n";                        $emailMsg = 'If you want to reset the password to your account: '.$user.'<br> Go <a href="http://superfuntime.comlu.com?ext=/scripts/resetpass.php?code='.$genCode.'">here</a>.';                        $sentEmail = mail($email, "Password Reset For $user", $emailMsg, $headers);                        if($sentEmail){                echo "<center><font color=green>An email has been sent to $maskedEmail!<br>The email may take up to 10 minutes to show up. Make sure you check your spam folder!</font></center>";            }

I also get this error in my config file:
Code:
PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in /home/cybert97/public_html/scripts/config.php on line 2
PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/cybert97/public_html/scripts/config.php:2) in /home/cybert97/public_html/scripts/config.php on line 2

A little bit of my config file script:
PHP:
<?phpsession_start();include("/home/cybert97/public_html/scripts/connectionfile.php");ini_set("session.cookie_httponly", true);ini_set('session.bug_compat_warn', 0);ini_set('session.bug_compat_42', 0);date_default_timezone_set("Europe/London");
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
As to the second problem, make 100% sure that there is nothing (even a single blank space) sent to the user prior to calling session_start. That includes white space before the opening <? tags.
 

cybert97

New Member
Messages
9
Reaction score
0
Points
0
I have done that, I checked convert to "UTF-8 WITHOUT BOM" and saved the file, still getting the error, even tried ob_clean(); but it still does it...
 

cybert97

New Member
Messages
9
Reaction score
0
Points
0
I've also noticed that the error is happening every 5 minutes, which is when my cronjob starts....
Cronjob (*/5 * * * * /usr/bin/php -f /home/cybert97/public_html/scripts/cronjob.php >/dev/null 2>&1 ) code:
PHP:
<?phpsession_start();include("/home/cybert97/public_html/scripts/config.php");$save_path = ini_get("session.save_path");$query = mysql_query("SELECT * FROM users WHERE loginID != ''");
while($row = mysql_fetch_array($query)){	$loginID = $row['loginID'];	$user = $row['username'];	if(!file_exists($save_path."/".$loginID)){		mysql_query("UPDATE users SET loginID = '' WHERE username = '$user'");	}}?>
 

Skizzerz

Contributors
Staff member
Contributors
Messages
2,928
Reaction score
118
Points
63
Your password reset emails are being blocked as spam by our outgoing mailserver -- I recommend editing the email template to make it look less spammy. Some suggestions:
1) Include the site name in the email
2) If you send an HTML email, wrap it in <html></html> tags (and all other required tags) to make it a valid HTML document
 
Status
Not open for further replies.
Top