DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

tips:mailconfig

Sending mails with SMTP

There is a plugin for swiftmail available that handles sending mails over external SMTP servers. Read on the plugins page for details.

Everything below is no longer needed and shouldn't be used unless there is a specific reason.

Sendmail for Windows

If you are looking for a way to make DokuWiki talk to any SMTP server, including one which might not be on the same machine, then you should probably look at this patch until DokuWiki itself can be updated to include this capability. This could be useful on any platform, not just Windows.

:?: If you are using Windows, wouldn't the “fake sendmail” program provide the same functionality? — Jeff 2007-02-27 20:49

:-? no way. after the patch in patch and hundred of attempts, mail are sent ONLY if I write all the mail addresses in $to instead of $bcc in mail.php. Using $bcc, mail are not sent. Sergio 2007-03-77 12:00

Windows-specific instructions

Due to all the layers involved, there are several ways to configure email.

Method #1: Using PHP to Send the Email Directly

Edit PHP.INI and set these variables (replace <mail.domain.tld> and <user@domain.tld> with the correct values):

; For Win32 only.
SMTP = <mail.domain.tld>
smtp_port = 25
sendmail_from = <user@domain.tld>

Restart the web server.

Method #2: Use the "Fake Sendmail" Program

Install Sendmail for Windows, from http://www.glob.com.au/sendmail/sendmail.zip. In PHP.INI, comment out the Win32 section that was used in Method #1 above, and instead enable this section (of course, specify the path to the “fake sendmail” program as it is on your system):

; For Unix only.  You may supply arguments as well (default: \"sendmail -t -i\").
sendmail_path = C:\HostingServices\SendMail\sendmail.exe

Note that if the path to sendmail.exe contains spaces then you may need to use 8.3 notation. For example, “C:\Progra~1\sendmail\sendmail.exe” instead of “C:\Program Files\sendmail\sendmail.exe”.

Next, edit sendmail.ini:

; you must change mail.mydomain.com to your smtp server
smtp_server=<mail.domain.tld>
; if your smtp server requires authentication, uncomment and modify the
; following two lines
;auth_username=
;auth_password=

Restart the web server.


1 Successful example of using sendmail in windows to configure REMOTE EXCHANGE server in PHP Dokuwiki

Im Ruby from WelcomeNetworks.com Canada. Today I have used sendmail in windows apache successfully. I had a remote exchange SMTP server which I had to configure to speak with Dokuwiki for my client, and I did it Successfully. This is how I did it:

*First I stored the sendmail in C:\Sendmail\Sendmail path directory.

* these settings in sendmail.ini in the sendmail folder smtp_server=your remote server's IP address(I used this) or Name AND smtp_port=25:

* php.ini file the path I gave for sendmail was like this– sendmail_path =“C:\sendmail\sendmail.exe -t”

Please note that people say that -t switch is for unix only, but I used this in windows today as of on 9th Oct 2008, and It WORKED. When I tried all other ways, nothing worked, this at last worked, Thank GOD
If you have any questions feel free to email me at ruby_brars@yahoo.com


Method #3: Use the "msmtp" SMTP client

There is another way of sending out e-mails using somebody's server. But “fake sendmail” doesn't support TLS. For those who want to use GMail SMTP server may do following:

  • Create configuration file named “msmtprc.txt” in one of the following folders: “C:\Documents and Settings\All Users\Application Data” or “C:\Documents and Settings\YOUR_LOGIN_NAME\Application Data”
account gmail
host smtp.gmail.com
auth on
user noreply@domainname.com
password blahblah
tls on
tls_starttls on
from noreply@domainname.com
maildomain domainname.com
account default : gmail
logfile msmtp.log
tls_certcheck off
  • Modify PHP.INI same way as described above. Comment out properties “SMTP”, “smtp_port” and “sendmail_from”. Uncomment “sendmail_path” and specify path to msmtp.exe. For example:
sendmail_path = c:\services\msmtp\msmtp.exe -t -i

Please note that path should NOT be enclosed into quotes, otherwise you will get “msmtp.exe: no recipients found” error.

  • Restart the web server.

One Example of Configuring Windows XP with PHP 5 using Method #2

My company's Dokuwiki server is running XP Pro with PHP and Apache provided by XAMPP, and the November 2006 release of Dokuwiki. Our email server is named simply “Exchange”.

I initially configured PHP.ini to use “exchange” as the smtp server (method #1 above), and this actually worked… only the link inside the “password reset” email came out malformed each time, so users couldn't reset their own passwords if they forgot them. To get around this, I ended up using the fake sendmail program and configuring it as follows.

So in PHP.ini (for XAMPP installations use C:\Program Files\xampp\apache\bin\php.ini), instead of specifying

; For Win32 only.
SMTP = exchange
smtp_port = 25

I commented those lines out and directed PHP to use the sendmail.exe program that ships with XAMPP (it's also available elsewhere; search for “fake sendmail”):

; For Unix only.
sendmail_path = "C:\Progra~1\xampp\sendmail\sendmail.exe -t"

Note that specifying “C:\Program Files” didn't work; I had to use the 8.3 notation of “Progra~1”.

Then, in the fake sendmail's config file, sendmail.ini, I just had to specify

smtp_server=exchange

After restarting Apache, emails then sent correctly from within Dokuwiki.

Comments

Sendmail for Linux

PHP and safe mode

If you are using the PHP safe mode, you will need to remove the fifth parameter from the mail command at the end of the mail_send function in the ./inc/mail.php file. – http://www.wikini.net/wakka.php?wiki=ProgFou

Could you specify which part and from where? Thanks! (php-beginner)

Change

return @mail($to,$subject,$body,$header,$params);

to

return @mail($to,$subject,$body,$header);

Unix (Linux) sendmail setup

If you're running DokuWiki on a machine without a functioning sendmail, and you use another machine for sendmail services, here's a couple of simple ways to get it going. (1) is the preferable solution, but (2) might also work.

(1) Edit /etc/php.ini, and change these lines

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

to look like this

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
sendmail_path = /usr/sbin/sendmail -s your.sendmail.host.com -t -i

Replace 'your.sendmail.host.com' with the name of the machine you use for sendmail services. Note that the ';' at the beginning of the line is removed. You may need to restart the web server for this to take effect (/etc/init.d/httpd restart). You may also have to add the respective user sending emails to the mail group. and restart php5-fpm (user logout).

(2) If for some reason you can't do (1), another solution is to create a script that pretends to be sendmail, and calls mini_sendmail instead. E.g.:

#!/bin/sh

/usr/sbin/mini_sendmail -syour.sendmail.host.com $@

Put these lines in a file called sendmail somewhere where PHP will find it and make the file executable (chmod +x /usr/sbin/sendmail for example). Of course you need to install mini_sendmail for this to work.

DokuWiki with an External Mail Server

When running a DokuWiki on Windows or other platforms you might find that you wish to use an SMTP server that does not reside on the same machine. Below find notes on how to accomplish this, especially with regards to a mail server that you do not administer. FIXME

:!: This patch to the 2006-11-06 version allows DokuWiki to talk to any SMTP server, including one which requires authentication.

Note: Windows installations can use the “fake sendmail” program to provide authentication instead of installing this patch. See Windows instructions for details.

(older comments)

Is there any news on making sendmail work on a server that one doesn't administer? — Alexander Kucera 2006/02/20 15:43

I would also like any news on running through a different SMTP server on the network. — Dennis Schulte 2006/04/25 16:24

I would also like any news on running through a different SMTP server on the network. — Paul Hoy 2006/09/16

I've not been successful in running Sendmail for Windows, yet. Has anyone managed to run Sendmail for Windows successfully? Thanks. – Straider (2004.09.02).
Try using sendmail_path = \“C:\HostingServices\SendMail\sendmail.exe -t -i\” as sendmail.exe requires -t to run and the Win32 version of PHP does not supply this by default as specified. – Jared (2005.23.01)
My dokuwiki server runs on windows - I am not admin but I think it uses sendmail. I got it running as follows:
  1. add \“ini_set('SMTP', $conf['smtphost']);\” to the top of mail.php
  2. set the mail server in local.php \“$conf['smtphost'] = 'your.smtp.host';\”
  3. in mail.php, delete the line \“$header = mail_encode_address($to, 'To');\” and change \“return @mail(null, …\” to \“return @mail($to, …\”
On Windows, with PHP properly installed to already know the SMTP and sendmail_from parameters, all I had to do was modify mail.php as described in the preceding note
My ISP uses qmail with a windows server. Any ideas how to configure this one?
After modify php.ini, remember to restart Apache server, or you will still get an error. – Fwolf (2005.09.07)
Try to use the first method which simply modifies PHP.ini. I failed with the second one which requires sendmail.exe but succeeded with the first one. :-D – Minyang (2006.12.05)
This may have been due to the 8.3 path issue mentioned in the Windows example. — Jeff 2007-02-27 20:38
tips/mailconfig.txt · Last modified: 2016-03-28 20:19 by 2001:4dd0:ff00:9581:357b:72dc:9aa0:fe56