[solved] MailCatcher or any other fake SMTP Server

Problems with the Linux version of XAMPP, questions, comments, and anything related.

[solved] MailCatcher or any other fake SMTP Server

Postby Nahuel » 17. June 2015 04:36

Hello! I'm running the latest XAMPP version on Ubuntu 15.04

I have been trying for TOO long to make the PHP mail() function work. On Windows, I had a little program called "Test mail server tool" which worked like a charm. No. configuration needed, no nothing. Just run it, and it would catch all mails sent to port 25.

All I really want is to be able to check how emails are being sent, I don't really want them to be sent.

I tried many options:

- Using Python as SMPT server (http://serverfault.com/questions/207619/how-to-setup-a-fake-smtp-server-to-catch-all-mails)
- Using FakeSMPT (https://nilhcem.github.io/FakeSMTP/)
- Actually using sendmail. I couldn't get it to work, I'm not that patient.
- Using MailCatcher (http://mailcatcher.me/)

I'm currently trying to make the latter work. But no matter what I try, mail() returns false and nothing is being sent to mailcatcher. This is my current php.ini

Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP=localhost
; http://php.net/smtp-port
smtp_port=2525

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = nahuel@nahueljose.com.ar

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
; sendmail_path = /usr/bin/env catchmail -f nahuel@nahueljose.com.ar
; sendmail_path = /usr/local/bin/catchmail
sendmail_path = "/usr/bin/env /usr/local/bin/catchmail"


And I run mailcatcher on port 2525 (I also tried their default port, same result). I tried using port 25, but mailcatcher says it's in use? At first it was, by sendmail, but I completely removed it and made sure port 25 wasn't being used ( sudo netstat -noa | grep ':25' ). Mailcatcher insists it is in use.

When I check /opt/lampp/logs/error_log, this appears at the end EVERY TIME I use mail()

Code: Select all
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': /usr/lib/x86_64-linux-gnu/ruby/2.1.0/digest/md5.so: symbol MD5_Init, version OPENSSL_1.0.0 not defined in file libcrypto.so.1.0.0 with link time reference - /usr/lib/x86_64-linux-gnu/ruby/2.1.0/digest/md5.so (LoadError)
   from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
   from /usr/lib/ruby/2.1.0/net/smtp.rb:23:in `<top (required)>'
   from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
   from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
   from /var/lib/gems/2.1.0/gems/mail-2.6.3/lib/mail.rb:8:in `<module:Mail>'
   from /var/lib/gems/2.1.0/gems/mail-2.6.3/lib/mail.rb:2:in `<top (required)>'
   from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
   from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
   from /var/lib/gems/2.1.0/gems/mailcatcher-0.6.1/bin/catchmail:7:in `rescue in <top (required)>'
   from /var/lib/gems/2.1.0/gems/mailcatcher-0.6.1/bin/catchmail:3:in `<top (required)>'
   from /usr/local/bin/catchmail:23:in `load'
   from /usr/local/bin/catchmail:23:in `<main>'


So it seems the problem is really with mailcatcher, but noone has this problem! Googling around the error (parts of it), someone said it might be because I have an old version of OpenSSL (vulnerable to heartbleed) so I manually updated OpenSSL to 1.0.1g (openssl version returns correct version). No change.

So, all I really need is to be able to see how emails are being sent. This is important to me because it needs to work locally before I upload to an online server.

Thank you!
Last edited by Nahuel on 17. June 2015 16:29, edited 1 time in total.
Nahuel
 
Posts: 2
Joined: 17. June 2015 04:18
Operating System: Ubuntu 15.04

Re: MailCatcher or any other fake SMTP Server

Postby Nobbie » 17. June 2015 15:30

I found this very handy description (but did not test it): http://distinctplace.com/2013/06/20/nul ... developer/

In order to use it, you should set SMTP to localhost, smtp_port to 25 and comment out sendmail_path - thats the way i would try. Restart Xampp after editing php.ini

Of course you have to de-install sendmail from Ubuntu, if you previously installed it, this would collide with Nullmailer.

P.S.: I already installed and checked it - it works. I accepted all defaults during installation of Nullmailer. After then i edited /etc/nullmailer/remotes and deleted the only one line (which contains only "mail") and instead i inserted one line "localhost smtp". I then restarted Nullmailer as descriped. Then i downloaded Fakemail, unpacked it into my Download folder. I created a mails folder in my home directory, then i proceeded to the Fakemail folder in my Downloads folder and entered in a terminal:

sudo ./fakemail.py --port 25 --path /home/myuserid/mails

where "myuserid" of course is my my UserID. Then i started a simple PHP Script with a mail() call, it finished with return value 1 and finally i found a text email in my new mails folder - everyting as expected.
Nobbie
 
Posts: 13182
Joined: 09. March 2008 13:04

Re: MailCatcher or any other fake SMTP Server

Postby Nahuel » 17. June 2015 16:08

Nobbie, thank you. That was easy, works perfectly! I still wonder why I couldn't get mailcatcher to work... Some problem with Ruby and OpenSSL apparently.

Oh well, this works for me. Solves my problem. Thanks a lot!
Nahuel
 
Posts: 2
Joined: 17. June 2015 04:18
Operating System: Ubuntu 15.04


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 55 guests