Hack to mail() function in emailer.php

The 2.0.x discussion forum has been locked; this will remain read-only. The 3.0.x discussion forum has been renamed phpBB Discussion.
Locked
senyahnoj
Registered User
Posts: 6
Joined: Mon May 09, 2005 9:33 am

Hack to mail() function in emailer.php

Post by senyahnoj » Tue Aug 02, 2005 5:32 pm

Using phpBB 2.0.17 and PHP 4.3.11 on Linux. /usr/sbin/sendmail on my box points to a postfix mailserver.

Found that my version of PHP seems to insist on a 5th parameter in the mail() function. The only way I can get phpBB to send email is via the following hack to includes/emailer.php (lines 212 and 227)

Was:

Code: Select all

 $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
Changed to:

Code: Select all

 $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers, "-f" . $this->from);
Has anyone else experienced this problem?

User avatar
romans1423
Registered User
Posts: 1545
Joined: Sat Nov 02, 2002 4:44 pm
Location: Connersville, IN
Name: Rick Beckman

Post by romans1423 » Wed Aug 03, 2005 12:44 am

Seems a whole lot like this MOD: :D

Code: Select all

############################################################## 
##   MOD Title:              Change Email Sender
##   MOD Version:            1.0.3
##
##   MOD Author:             N/A - < mewsite@comcast.net > - (Michael Warkander) - http://www.mew.ssxh.net (do not contact for support)
##   MOD Author, Secondary:  Plastikaa - < mmckenna@gmail.com > - (N/A) - httP://www.plastikaa.com
##
##   MOD Description:        When Emails are sent from within phpBB, such as the confirm registration email
##                           these Emails come from your servers default email (usually something 
##                           such as: nobody@your_hosts_server.com) - Due to some hosts starting to disable 
##                           sending emails from this Email address to reduce spam phpBB is unable 
##                           to send these Emails. These two small changes will make all the emails phpBB sends come from 
##                           the board's email adddress rather than the servers default address.
##
##                           Please note: although the email address the emails come from in phpBB before applying this change 
##                           say they come from the boards email, they don't! This is a simple php mail function to make it  
##                           appear as if they do. This change won't make any visual difference to most people but its an 
##                           important change.
##                     
##   Installation Level:     Easy 
##   Installation Time:      1 minute 
##
##   Files To Edit:          includes/emailer.php
##   Included Files:         None 
##
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: This MOD is for download from http://www.plastikaa.com , http://www.phpbb.com , http://www.phpbbhacks.com
## only. If you downloaded this hack from any other location it might not be the latest version and so should be reported
## to http://www.plastikaa.com as soon as possible, thankyou.
##
##   Compatibility:       2.0.5 - 2.0.10
##   Support:             http://www.forum.plastikaa.com
##   Copyright:           Copyright © 2004 Plastikaa
##
##   This hack is released under the GPL License. 
##   This hack can be freely used, but not distributed, without permission. 
##   Intellectual Property is retained by the hack author(s) listed above. 
############################################################## 
## MOD History: 
##
##   2004-11-06 - Version 1.00 
##      - Initial Release
##
##   2004-11-10 - Version 1.01 
##      - Modification about information changes
##
##   2004-11-10 - Version 1.02 
##      - Modification about information changes 
##
##   2004-11-10 - Version 1.0.3 
##      - Reformatting of Version Numbers and slight code alteration. 
## 
##############################################################  
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

#
#-----[ OPEN ]----------------------------------------------
#
includes/emailer.php


#
#-----[ FIND ]----------------------------------------------
#
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);


#
#-----[ REPLACE WITH ]--------------------------------------
#
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers, "-f{$board_config['board_email']}"); 


#
#-----[ FIND ]----------------------------------------------
#
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);


#
#-----[ REPLACE WITH ]--------------------------------------
#
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers, "-f{$board_config['board_email']}"); 


# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 

senyahnoj
Registered User
Posts: 6
Joined: Mon May 09, 2005 9:33 am

Excellent

Post by senyahnoj » Wed Aug 03, 2005 1:00 pm

I think I prefer ${board_config['board_email']} to $this->from

Very useful. Cheers!

HerrB
Registered User
Posts: 1
Joined: Thu Dec 23, 2004 11:18 am

Post by HerrB » Mon Nov 28, 2005 11:52 pm

I'd like to add, that this mod (means: the additional 5th parameter) solves also a line 234 emailer.php error message (and should be referenced in the Knowledge Base :wink: ).

Regards,
HerrB

Locked

Return to “2.0.x Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests