News:

Join the Facebook Fan Page.

Main Menu

mail_from

Started by akc42, February 23, 2014, 02:53:59 AM

Previous topic - Next topic

akc42

I am trying to make my forum send mail messages on behalf of the owner of the forum as opposed to me, the person who gets messages to the local www-data account, since at the moment I am getting all the bounce messages for newsletters and other messages to users who have in invalid e-mail address.

In examining the source in Subs-Post.php, the sendmail function there is looking at a mod_setting "mail_from" to determine what to set the return path to.  It is (probably) finding a null value and so does not include the return path.  That is making it default to www-data

I am searching the code looking at how this mod_setting can be set, but I can't find any other reference to it in the source.

I suppose I could manually edit the database and insert that setting, but I don't want to unless there is no other choice. 

Can anyone help me by explaining how it gets set.

Thanks

Kindred

the forum sends mail from whatever account you have set as the admin email address in smf admin settings.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

akc42

Quote from: Kindred on February 23, 2014, 09:22:23 AM
the forum sends mail from whatever account you have set as the admin email address in smf admin settings.

I think the mail_from is a bit of a red herring.  I've been looking more closely, and it is never set, but is always defaulted if it never set to $webmaster_email.  I am pretty sure that is set up to be the admin mail address to which you refer.

This value (coupled with the Forum Name) is what appears in the "From:" header of the e-mail.  the sendmail function inside of SMF builds the headers and this is one of them. But when SMF sends it to PHP it only uses the to,subject,message, and headers parameters of the mail function and not the 5th parameter of the call, the additional_parameters value. This means that sendmail (the unix application, not the SMF function) uses the account that it was called from to set the "envelope sender".

I have changed line 760 of Subs-Post.php to add the -f parameter to sendmail - thus

if (!mail(strtr($to, array("\r" => '', "\n" => '')), $subject, $message, $headers,"-f".$webmaster_email))

And this appears to correct the issue - now the mail is sent as the forum admin.

(because its submitted by sendmail, my mail hub - postfix - doesn't worry that this is not an address it is responsible for)

I'm a little nervous that I will have to maintain this as a parallel patch to the SMF distribution, but I think it solves my problem

Advertisement: