Trouble Sending Email

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
scrypte
Forum Newbie
Posts: 6
Joined: Sat Nov 06, 2004 3:31 pm

Trouble Sending Email

Post by scrypte »

I'm having trouble with one of my cron jobs, as its not sending out the email like it is supposed to:

Code: Select all

<?php

/**
 * @name report.cron.php
 *
 * @desc This file is the report generation cron job for the
 * Administrative backend to be used by the Data Entry Clerks that
 * are either contracted or in-house for The SCORE Group. This report
 * outlines all information entered by a Data Entry Clerk on a given day
 * for verification purposes when request of payment for work
 * performed is provided by contract Data Entry Clerks.
 *
 * @copyright 2006 The SCORE Group
 * @author Jonathan Bradley <bradleyj at scoregroup dot com>
 * @package Model Directory
 * @version  1.0.0
 */

 // CONFIGURATION FILES
 include ('../config.php');
 include('../functions/functions.admin.misc.php');


function cron_entry_report () {
 // SET DEFAULTS
 $todays_date = date('Y-m-d');

 // REPORT TITLE
 echo '<p>&nbsp;</p>
 <p>&nbsp;</p>
 <div style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center;">Data Entry Clerk Report</div>
 <div style="font-family:tahoma; font-size: 8pt; text-align: center;">For: '. $todays_date.'</div>
 <br />';

 // START TABLE
 echo '<table border="1" cellspacing="0" cellpadding="4" rules="all" bordercolor="#A1ABB8" align="center">
            <tr bgcolor="#D2D7E3">
                    <td style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center; width: 125px;">Username</td>
                    <td style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center; width: 200px;">Full Name</td>
                    <td style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center; width: 75px;"># of Models</td>
                    <td style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center; width: 100px;"># of Postings</td>
                    <td style="font-family:tahoma; font-size: 9pt; font-weight: bold; text-align: center; width: 125px;"># of Publications</td>
                   </tr>';

 // GET CLERK INFORMATION
 $sql = "SELECT username,firstname,lastname FROM md_users WHERE access='data'";
 $query = mysql_query($sql);
 for ($i=0; $i<$arr = mysql_fetch_array($query); $i++)
 {

        echo '<tr bgcolor="'.row_color($i).'">';

         // GET NEW MODELS ADDED
        $m_sql = "SELECT * FROM md_models WHERE addedby='".$arr['username']."' && added='".$todays_date ."'";
        $m_q = @mysql_query($m_sql);
        $total_models = @mysql_num_rows($m_q);

        // GET NEW POSTINGS ADDED
        $post_sql = "SELECT * FROM md_posting WHERE addedby='".$arr['username']."' && added='".$todays_date ."'";
        $post_q = @mysql_query($post_sql);
        $total_postings = @mysql_num_rows($post_q);

        // GET NEW PRODUCTS ADDED
        $prod_sql = "SELECT * FROM md_publications WHERE addedby='".$arr['username']."' && added='".$todays_date ."'";
        $prod_q = @mysql_query($prod_sql);
        $total_publications = @mysql_num_rows($prod_q);

        echo '<td style="font-family:tahoma; font-size: 9pt; padding-left: 5px;">'.$arr['username'].'</td>
                    <td style="font-family:tahoma; font-size: 9pt; padding-left: 5px;">'.$arr['firstname'].' '.$arr['lastname'].'</td>
                    <td align="center" style="font-family:tahoma; font-size: 9pt;">'.$total_models.'</td>
                    <td align="center" style="font-family:tahoma; font-size: 9pt;">'.$total_postings.'</td>
                    <td align="center" style="font-family:tahoma; font-size: 9pt;">'.$total_publications.'</td>
            </tr>';
 }
 echo '</table>';

}

$body = cron_entry_report();

$hdrs  = "Sender: model@scoregroup.com
Reply-To: model@scoregroup.com";

mail("scrypte@gmail.com", "Data Entry Report", $body, $hdrs);
?>
All I get is something that Says
From: Apache
Subject: Data Entry Report

and the body is 100% empty.

Any ideas?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your function uses echo. Your code is under the assumption the function is returning a string.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

What I would do is, instead of echoing, assign it to a varible.

Code: Select all

$output = '';

//do some function stuff

$output .= $function_result;

return $output;
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply