From 3c0cfd3fc8536f9dcabd48c0ec2cebd510cdd9cf Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Wed, 8 Sep 2004 08:57:52 +0000 Subject: [PATCH] Have WP mailed post come from author if email matches author in DB. Hat tip: Jerome Cornet. git-svn-id: https://develop.svn.wordpress.org/trunk@1624 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-mail.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-mail.php b/wp-mail.php index a46e55923c..8348125b29 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -65,6 +65,22 @@ for ($i=1; $i <= $count; $i++) : $subject = explode($phone_delim, $subject); $subject = $subject[0]; } + + // Set the author using the email address (To or Reply-To, the last used) + // otherwise use the site admin + if (preg_match('/From: /', $line) | preg_match('Reply-To: /', $line)) { + $author=trim($line); + if ( ereg("([a-zA-Z0-9\_\-\.]+@[\a-zA-z0-9\_\-\.]+)", $author , $regs) ) { + echo "Author = {$regs[1]}

"; + $result = $wpdb->get_row("SELECT ID FROM $tableusers WHERE user_email='$regs[1]' ORDER BY ID DESC LIMIT 1"); + if (!$result) + $post_author = 1; + else + $post_author = $result->ID; + } else + $post_author = 1; + } + if (preg_match('/Date: /i', $line)) { // of the form '20 Mar 2002 20:32:37' $ddate = trim($line); $ddate = str_replace('Date: ', '', $ddate); @@ -130,6 +146,7 @@ for ($i=1; $i <= $count; $i++) : do_action('publish_phone', $post_ID); + echo "\n

Author: $post_author

"; echo "\n

Posted title: $post_title
"; echo "\nPosted content:

".$content.'

';