MyBB Community Forums

Full Version: method for sending mail
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Not sure you chose a good idea for sending email from the bulletin board. It appears you get the host email account from the php.ini. On the hosting service I'm on, I have no access to that file and the support person I talked to seemed reluctant to change it's settings, instead showing me code I could use to send mail.

Well, I tried to alter the code in inc/functions.php file to reflect what the service expected and crashed the board. Luckily uploading the original fuctions.php file fixed what I broke.

I'm switching my user registration now to not require email activation until I figure out how to get around this. Couldn't there be instead database entries containing the email, username, password, etc. necessary to send mail from the application? Seems like giving the forum administrator the power to control this would make more sense than throwing the responsibility to the web host.

Art Martin

Oh, and by the way, what a putz I am for whining before I thanked the team for such a fine and free product. I'm really blown away by its power.
It should by default send out all emails from the email address you provide during the setup (ie the one defined in the settings area of the Admin CP). If it isn't then it would be a restriction your host has placed on your server/copy of PHP.
Chris, I think just knowing the email address isn't enough for some hosting sites. Mine has a password associated with it. I didn't see any parameter where you could save that. That's why I said the logical place for info like that is in the database where prying eyes can't discover it easily.

It appeared that the bb uses a common function for sending mail out and that function resides in the functions.php file in the "inc" folder. I tried a test of altering that file with the intent of writing my own custom mail send routine but it absolutely crashed the board with messages to the equivalent of me needing a finger removed for even considering it. Is there something special about a file like that one or is it just my lack of knowledge of php programming that's limiting me here? Even though I'm a very good programmer on business applications, this is new territory to me.

Art
The problem is that it's using the mail function. That takes the email address it's actually sent from and your mail function is just setting the From header. It's not actually sending the mail from a certain account. It's sending it from the default one.
I had this problem on one server (my own tests using mail). It was sending from the hosts' default address, which was something like [email protected].
From php.net
Quote: For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.
You might be able to change who it's sent from by preforming an
@ini_set('sendmail_form', "[email protected]");