[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

emails aint sending

ok i have my code below that checks to see if a user wants to recive emails about new posts on a topic...
but my emails are not been sent

i var_dunm($row) and got

 array(5) { ["user_id"]=>  string(1) "1" ["topic_id"]=>  string(3) "484" ["mailed"]=>  string(1) "1" ["email"]=>  string(25) "admin@runningprofiles.com" ["ID"]=>  string(1) "1" }

so its getting the data ... any 1 figure out why the emails aint been sent to me
<?php $query = "SELECT fe.*, u.email, u.ID FROM forum_email as fe INNER JOIN users as u ON u.ID = fe.user_id WHERE fe.topic_id = " . $forumpostid . "  AND fe.mailed=1";
$res = mysql_query($query) or die ("$query fails : ".mysql_error());
//$row = mysql_fetch_assoc($res);
//var_dump($row);
//echo $forumpostid; echo $id;
//nobody wants an email, stop now
if(mysql_num_rows($res)==0)
{
 echo "no records returned";
        exit;
}
 
// ADDED CODE TO SEND EMAIL MESSAGES
$subj = 'Forum Updated';
$from = ' [your return information ] ';
$text = ' [your message text] ';
 
while ($row = mysql_fetch_assoc($res)) {
        extract ($row);
        if (!mail($email, $subj, $text, $from)) {
                echo "<br />MAIL FAILED FOR $email \n";
        }
}

Open in new window

0
runnerjp
Asked:
runnerjp
  • 2
1 Solution
 
Roger BaklundCommented:
What is in the $from variable? This is used as mail headers, and must be formatted correctly.

http://php.net/manual/en/function.mail.php
0
 
Ray PaseurCommented:
@runerjp: Isn't this what we are talking about in another thread? ~Ray

Try changing the mail command to OMIT the from field, like this on line 20.
        if (!mail($email, $subj, $text)) {

Open in new window

0
 
Ray PaseurCommented:
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now