Hello community!
Wrote the extension for PhpMailer yesterday, but need some more
information on MediaWiki mail and extension writing overall.
a) Refering to
https://doc.wikimedia.org/mediawiki-core/master/php/html/UserMailer_8php_so…,
what is the difference of $name and $realname of a MailAddress object and
how do I handle it when assigning TO and FROM of mail?
b) How are attachments handled? Are there any with MediaWiki's UserMailer?
c) Regarding programming conventions, are there more things to pay
attention to than mentioned here:
http://www.mediawiki.org/wiki/Manual:Developing_extensions ?
d) Is there anyone out there willing to review the code/extension when it
is ready?
Thank you for reading,
Paule
Am 18.11.2013, 14:15 Uhr, schrieb Daniel Friesen
<daniel(a)nadir-seen-fire.com>om>:
On 2013-11-18 4:42 AM, Matthias Paul wrote:
Am 18.11.2013, 11:38 Uhr, schrieb Daniel Friesen
<daniel(a)nadir-seen-fire.com>om>:
On 2013-11-18 1:07 AM, Matthias Paul wrote:
I'm trying to install a MediaWiki instance.
Although I never worked
with MediaWiki before, I feel quite comfortable with server issues
(*nix) and PHP.
I'd like to have mail support in the MW instance. Unfortunately I
cannot rely on sendmail (or even mini_sendmail) binary in my
installation for several reasons - both requiring a shell binary.
It seems, it's possible to replace original PHP's mail() command by an
alternate mailer program.
Have you tried using $wgSMTP?
No, I didn't. It says: "This setting requires PEAR's Mail package to
be installed [..]" and your response seems to direct me to _not_ use
PEAR-Mail.
Go ahead and try $wgSMTP, I'm not telling you not to use
PEAR-Mail.
Library wise PHPMailer is better than PEAR-Mail, but PEAR-Mail still
works fine.
Our code in this area IS legacy, but PEAR-Mail does work.
So go ahead and use PEAR-Mail if it works.
Using the PHPMailer instead of mail() or PEAR-Mail is just a backend
technical detail relevant to developers writing MW core.
It's not relevant to simply running a wiki. Even if you started using
$wgSMTP now and in the future we decided to overhaul
includes/UserMailer.php to completely use PHPMailer instead it would be
completely backwards compatible. Your wiki would continue to seamlessly
run even after you upgraded.
If you've got an issue of not being able to use the PEAR tools it should
be possible to use it.
PEAR-Mail is simply required from the install path. So you can just
download PEAR-Mail from PEAR's website and dump it somewhere in the
install path.
You can either modify the install path using LocalSettings.php to
include the directory PEAR-Mail is inside or dump it into a directory
that is already on the install path (eg: I'm not sure but $IP might be
in it. If so you could just dump it alongside the MW code.)
b) I read about hooks in mailer class code (line 288
of
https://doc.wikimedia.org/mediawiki-core/master/php/html/UserMailer_8php_so…):
$ret = wfRunHooks( 'AlternateUserMailer', array( $headers, $to, $from,
$subject, $body ) );
Is this hook meant to replace the original mail program?
Yes that hook allows an
extension to override the mail()/PEAR::Mail
handling and implement an alternative mailer backend.
c) Did anyone replace original mailing code by
PHPMailer yet?
Not that I know of. But it would be a nice project.
PHPMailer is pretty nice, it's even in composer too.
Which makes me a little happy, while also reminding me that someone has
made a "feature" our lack of a composer.json file – which we could
otherwise have put a PHPMailer into, incorporated composer into the
release process depending on libraries directly, and not having to go
and shove a big blob of 3rd party code into our codebase with
absolutely
no handling for when it becomes outdated.
I'm not sure, if I understood your answer on c. I havent worked with
Composer or MediaWiki code-wise yet.
Composer is a dependency-management tool, which allows to package
components (e.g. PhpMailer) as extension? Will the extension be the
"AlternateUsermailer" hook, bundled with dependency on PhpMailer?
Yes,
composer is a dependency-management tool, but for PHP libraries.
Using it we'd have a composer.json file that listed PHPMailer and a
version as a dependency and running `{command to execute composer}
install` would install/bundle PHPMailer locally and also allow you to
update it and monitor it for updates.
For MediaWiki releases we'd incorporate that composer run into the
release process so that tarball users still have every library they need
out of the box.
You can ignore my comments about it, I'm just griping about something
semi-relevant to the idea of incorporating PHPMailer directly into core.
If you wanted to implement PHPMailer in an extension, yes the extension
would *use* the AlternateUserMailer hook.
By registering a hook function using $wgHooks or Hooks::register.
And then implementing the code to send the email using PHPMailer instead
of PEAR::Mail or mail().So far, thank you for your answers :)
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [
http://danielfriesen.name/]
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
--
Matthias Paul
FOCUS electronics GmbH
Entwicklungsabteilung
Naumburger Str. 28
D - 04229 Leipzig
Phone: +49-(0)341-47834-47
Fax: +49-(0)341-47834-48
E-Mail: m.paul(a)focus-gmbh.com
Amtsgericht Leipzig HRB 18309
Geschäftsführer: Dr. Michael Merkel