[Bb-trac] Re: [bbPress] #749: bb_mail fails to sent mail

bbPress bb-trac at lists.bbpress.org
Mon Oct 8 21:46:05 GMT 2007


#749: bb_mail fails to sent mail
----------------------------+-----------------------------------------------
 Reporter:  snakefoot       |        Owner:  mdawaffe     
     Type:  defect          |       Status:  assigned     
 Priority:  normal          |    Milestone:  0.8.4 & Pings
Component:  Administration  |      Version:  0.8.3        
 Severity:  normal          |   Resolution:               
 Keywords:                  |  
----------------------------+-----------------------------------------------
Comment (by snakefoot):

 The problem is that the hotmail spam filter doesn't like the following
 things in the header (Marked with bold):

 '''\n'''From: '''Forum Name<''' bbpress at forum.com '''>'''

 The newline before the "From" makes it reject the mail.[[BR]]
 The alternative name instead of just the e-mail address makes it reject
 the mail.

 This makes it much happier:

 From: bbpress at forum.com\n

 A corrected version that doesn't use the admin email:

 {{{
         $headers = trim($headers);
         if ( !preg_match( '/^from:\s/im', $headers ) ) {

                 $from_host = parse_url( bb_get_option( 'domain' ) );
                 if ( !$from || !$from['host'] ) {
                         $from_host = preg_replace('#^www\.#', '',
 strtolower($_SERVER['SERVER_NAME']));
                 } else {
                         $from_host = $from_host['host'];
                         if ( substr( $from_host, 0, 4 ) == 'www.' )
                                 $from_host = substr( $from_host, 4 );
                 }

                 if (!empty($headers))
                         $headers .= '\n';
                 $headers .= 'From: ' . 'bbpress@' . $from_host;
                 $headers = trim($headers);
         }

         return @mail( $to, $subject, $message, $headers );
 }}}

 wp_mail from Wordpress adapted to bbpress (Also works with hotmail):

 {{{
         if( $headers == '' ) {
                 $headers = "MIME-Version: 1.0\n" .
                         "From: bbpress@" . preg_replace('#^www\.#', '',
 strtolower($_SERVER['SERVER_NAME'])) . "\n" .
                         "Content-Type: text/plain; charset=\"" .
 bb_get_option('charset') . "\"\n";
         }

         return @mail($to, $subject, $message, $headers);
 }}}

 Another solution could be to check for hotmail in the to-address and then
 change behavior accordingly.

-- 
Ticket URL: <http://trac.bbpress.org/ticket/749#comment:4>
bbPress <http://bbpress.org/>
Innovative forum development


More information about the Bb-trac mailing list