View Single Post
  #6  
Old 20th January 2006, 01:50
palkat palkat is offline
Member
 
Join Date: Aug 2005
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by falko
What about the code that produces the mails? Does it generate full headers? Please post this code here (only the code that generates the emails).
Here is the code from one program where it will not deliver to AOL. this is GEEKLOG and the code is to send an article to a person via email.

/**
* This will email new stories in the topics that the user is interested in
*
* In account information the user can specify which topics for which they
* will receive any new article for in a daily digest.
*
* @return void
*/

function COM_emailUserTopics()
{
global $_CONF, $_TABLES, $LANG08, $LANG24;

$subject = strip_tags( $_CONF['site_name'] . $LANG08[30] . strftime( '%Y-%m-%d', time() ));

$authors = array();

// Get users who want stories emailed to them
$usersql = "SELECT username,email,etids,{$_TABLES['users']}.uid AS uuid "
. "FROM {$_TABLES['users']}, {$_TABLES['userindex']} "
. "WHERE {$_TABLES['users']}.uid > 1 AND {$_TABLES['userindex']}.uid = {$_TABLES['users']}.uid AND (etids <> '-') ORDER BY {$_TABLES['users']}.uid";

$users = DB_query( $usersql );
$nrows = DB_numRows( $users );

$lastrun = DB_getItem( $_TABLES['vars'], 'value', "name = 'lastemailedstories'" );

// For each user, pull the stories they want and email it to them
for( $x = 1; $x <= $nrows; $x++ )
{
$U = DB_fetchArray( $users );

$storysql = "SELECT sid,uid,date AS day,title,introtext,bodytext "
. "FROM {$_TABLES['stories']} "
. "WHERE draft_flag = 0 AND date <= NOW() AND date >= '{$lastrun}'";

$topicsql = "SELECT tid FROM {$_TABLES['topics']}"
. COM_getPermSQL( 'WHERE', $U['uuid'] );
$tresult = DB_query( $topicsql );
$trows = DB_numRows( $tresult );

if( $trows == 0 )
{
// this user doesn't seem to have access to any topics ...
continue;
}

$TIDS = array();
for( $i = 1; $i <= $trows; $i++ )
{
$T = DB_fetchArray( $tresult );
$TIDS[] = $T['tid'];
}

if( !empty( $U['etids'] ))
{
$ETIDS = explode( ' ', $U['etids'] );
$TIDS = array_intersect( $TIDS, $ETIDS );
}

if( sizeof( $TIDS ) > 0)
{
$storysql .= " AND (tid IN ('" . implode( "','", $TIDS ) . "'))";
}

$storysql .= COM_getPermSQL( 'AND', $U['uuid'] );
$storysql .= ' ORDER BY featured DESC, date DESC';

$stories = DB_query( $storysql );
$nsrows = DB_numRows( $stories );

if( $nsrows == 0 )
{
// If no new stories where pulled for this user, continue with next
continue;
}

$mailtext = $LANG08[29] . strftime( $_CONF['shortdate'], time() ) . "\n";

for( $y = 0; $y < $nsrows; $y++ )
{
// Loop through stories building the requested email message
$S = DB_fetchArray( $stories );

$mailtext .= "\n------------------------------\n\n";
$mailtext .= "$LANG08[31]: "
. COM_undoSpecialChars( stripslashes( $S['title'] )) . "\n";
if( $_CONF['contributedbyline'] == 1 )
{
if( empty( $authors[$S['uid']] ))
{
$storyauthor = DB_getItem( $_TABLES['users'], 'username', "uid = '{$S['uid']}'" );
$authors[$S['uid']] = $storyauthor;
}
else
{
$storyauthor = $authors[$S['uid']];
}
$mailtext .= "$LANG24[7]: " . $storyauthor . "\n";
}

$mailtext .= "$LANG08[32]: " . strftime( $_CONF['date'], strtotime( $S['day' ])) . "\n\n";

if( $_CONF['emailstorieslength'] > 0 )
{
$storytext = COM_undoSpecialChars( stripslashes( strip_tags( $S['introtext'] )));

if( $_CONF['emailstorieslength'] > 1 )
{
if( strlen( $storytext ) > $_CONF['emailstorieslength'] )
{
$storytext = substr( $storytext, 0, $_CONF['emailstorieslength'] ) . '...';
}
}

$mailtext .= $storytext . "\n\n";
}

$mailtext .= $LANG08[33] . ' ' . COM_buildUrl( $_CONF['site_url']
. '/article.php?story=' . $S['sid'] ) . "\n";
}

$mailtext .= "\n------------------------------\n";
$mailtext .= "\n$LANG08[34]\n";
$mailtext .= "\n------------------------------\n";

$mailto = $U['username'] . ' <' . $U['email'] . '>';

COM_mail( $mailto, $subject, $mailtext );
}

DB_query( "UPDATE {$_TABLES['vars']} SET value = NOW() WHERE name = 'lastemailedstories'" );
}
Reply With Quote