DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:mailconfig

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:mailconfig [2010-08-19 00:19] 93.205.254.96tips:mailconfig [2024-02-02 17:15] (current) – old revision restored (2018-01-25 15:14) Aleksandr
Line 1: Line 1:
-====== Erste Versuch mit der dokuwiki-Syntax ======+====== Sending mails with SMTP ======
  
 +There is a [[plugin:smtp|SMTP Plugin]] available that handles sending mails over external SMTP servers. Read on the [[plugin:smtp|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 [[http://www.metakitto.com/doku.php?id=wiki:dokuwiki_smtp_patch|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?  --- //[[spamact@yahoo.com|Jeff]] 2007-02-27 20:49//
 +
 +:-? no way. after the patch in [[http://www.metakitto.com/doku.php?id=wiki:dokuwiki_smtp_patch|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. //[[s.petruzzelli@gmail.com|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):
  
 <code ini> <code ini>
-#!/usr/bin/perl +For Win32 only. 
-use Getopt::Std+SMTP = <mail.domain.tld> 
-use Term::ReadKey; +smtp_port = 25 
-use Net::Twitter; +sendmail_from <user@domain.tld> 
-getopt('upt',\%opts); +</code>
-#$usage= <<USAGE; +
-#commandline twitter 0.1b - www.j-zero.de +
-#Usage: twitter_cmd -u username [-t tweet] [-p password] +
-#USAGE +
-sub gp{ +
-    print "password: "; +
-    ReadMode 2; +
-    chomp($l ReadLine(0));  +
-    ReadMode 0; +
-    print "\n"; +
-    return $l; +
-+
-if(!$opts{u}){print $usage;exit 1;} +
-    else{$u=$opts{u};}+
  
-if(!$opts{t}){print "tweet: ";chomp($t=<STDIN>);+Restart the web server.
-    else{$t=$opts{t};}+
  
-if(!$opts{p}){$p=&gp;} + 
-    else{$p=$opts{p};} + 
-$s=Net::Twitter->new({username=>"$u",password=>"$p}); + 
-$s->update({status=>"$t"}); +==== Method #2: Use the "Fake SendmailProgram ==== 
-exit 0;+ 
 +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 sendmailprogram as it is on your system): 
 + 
 +<code ini> 
 +; For Unix only.  You may supply arguments as well (default: \"sendmail --i\"). 
 +sendmail_path = C:\HostingServices\SendMail\sendmail.exe
 </code> </code>
  
 +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:
 +
 +<code 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=
 +</code>
 +
 +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:
 +
 +  * Download "msmtp" from http://sourceforge.net/projects/msmtp/
 +
 +  * 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"
 +
 +<code ini>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</code>
 +
 +  * 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:
 +<code>sendmail_path = c:\services\msmtp\msmtp.exe -t -i</code>
 +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
 +
 +<code ini>
 +; For Win32 only.
 +SMTP = exchange
 +smtp_port = 25
 +</code>
 +
 +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"):
 +
 +<code ini>
 +; For Unix only.
 +sendmail_path = "C:\Progra~1\xampp\sendmail\sendmail.exe -t"
 +</code>
 +
 +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
 +
 +<code ini>
 +smtp_server=exchange
 +</code>
 +
 +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
 +<file>
 +return @mail($to,$subject,$body,$header,$params);
 +</file>
 +to
 +<file>
 +return @mail($to,$subject,$body,$header);
 +</file>
 +===== 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
 +
 +<file>
 +; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
 +;sendmail_path =
 +</file>
 +
 +to look like this
 +
 +<file>
 +; 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
 +</file>
 +
 +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.:
 +
 +<file>
 +#!/bin/sh
 +
 +/usr/sbin/mini_sendmail -syour.sendmail.host.com $@
 +</file>
 +
 +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 [[http://www.acme.com/software/mini_sendmail/|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 [[http://www.metakitto.com/doku.php?id=wiki:dokuwiki_smtp_patch|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-specific instructions|Windows instructions]] for details.
 +
 +===== (older comments) =====
 +
 +Is there any news on making sendmail work on a server that one doesn't administer? --- //[[a.kucera@babylondreams.de|Alexander Kucera]] 2006/02/20 15:43//
 +
 +I would also like any news on running through a different SMTP server on the network.   --- //[[dschulte@informationexperts.com|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:
 +
 +  - add \"ini_set('SMTP', $conf['smtphost']);\" to the top of mail.php
 +  - set the mail server in local.php \"$conf['smtphost'] = 'your.smtp.host';\"
 +  - 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 [[#One Example of Configuring Windows XP with PHP 5 using Method #2|Windows example]].  --- //[[spamact@yahoo.com|Jeff]] 2007-02-27 20:38//
tips/mailconfig.1282169975.txt.gz · Last modified: 2010-08-19 00:19 by 93.205.254.96

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki