Issue Details (XML | Word | Printable)

Key: JRUBY-1878
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Critical Critical
Assignee: Thomas E Enebo
Reporter: Raphael Valyi
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
JRuby

Failing to send mails to msmtp mail server using IO.popen. For instance impossible to send mails to GMail using msmtp. This is a regression.

Created: 03/Jan/08 06:37 PM   Updated: 23/Apr/08 10:03 AM   Resolved: 05/Jan/08 01:54 PM
Return to search
Component/s: None
Affects Version/s: JRuby 1.x+
Fix Version/s: JRuby 1.1RC1

Time Tracking:
Not Specified

Environment: JRuby head. Two weeks ago or now January the 4th. Ubuntu Linux, java version "1.6.0_10-ea"

Testcase included: yes


 Description  « Hide

Unless you are able to reduce the test by inspecting what is sent by IO.popen, you need to set an msmtp server, for instance to send mails to your gmail account (don't you have a gmail account?). This should be simple.

so apt-get install msmtp.
Then make it work for gmail: edit or creat the .msmtprc file in your home directory and write inside:
account gmail
host smtp.gmail.com
auth on
user your_login@gmail.com
password your_password
tls on
tls_starttls on
tls_certcheck off
from your_login@gmail.com
maildomain gmail.com

Then try this in MRI and then in JRuby (also chekc your mail box):

s = "Date: Fri, 4 Jan 2008 01:00:05 +0100
From: livetribune@gmail.com
To: 'rvalyi@gmail.com' <rvalyi@gmail.com>
Subject: How good is JRuby?
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

Look at your mail box to discover"

IO.popen("/usr/bin/msmtp -t -C /home/rvalyi/.msmtprc -a gmail --", "w") do |sm|
sm.puts(s.gsub(/\r/, ''))
sm.flush
end

if $? != 0
puts "failed to send mail errno #{$? >> 8}"
end

In MRI you should get nil and receive the e-mail while in JRuby, you would get no email and that error line in your terminal:
failed to send mail errno 143

Ant idea what is going wrong?



Stephen Bannasch added a comment - 03/Jan/08 06:54 PM

I think this is related to JRUBY-1857 and JRUBY-1557.

The problem occurs when sending multiple parameters of certain types out through system exec using backtic, ruby's system and IO.popen.


Thomas E Enebo added a comment - 04/Jan/08 10:27 AM

I am looking at this today...I suspect this will open up a can of popen...


Thomas E Enebo added a comment - 04/Jan/08 04:08 PM

Fixed in commit 5500 on trunk. We were unconditionally calling process.destroy which would kill a process in some cases before it had finished.


Raphael Valyi added a comment - 05/Jan/08 10:35 AM

Tom,

I'm sorry but it's still not working. You might have fixed something, but then A NEW ISSUE appeared. Now, using the same test, I'm getting an error earlier:
in JRuby heard, I now have in jirb:

irb(main):035:0> IO.popen("/usr/bin/msmtp -t /home/rvalyi/.msmtprc -a gmail", "w") do |sm|
irb(main):036:1* sm.puts("Hello world")
irb(main):037:1> sm.flush
irb(main):038:1> end
Errno::EPIPE: Broken pipe

This is a new issue that wasn't there yesterday. Please mail me or ask me on the irc if you need more details or tests.

Hope this helps.


Marcin Mielzynski added a comment - 05/Jan/08 10:37 AM

Reopening. Raphael says there's some other issues.


Stephen Bannasch added a comment - 05/Jan/08 10:56 AM

On my MacOS 10.4.11, Java 1.5.0_13, JRuby trunk system.

This works:

IO.popen("ifconfig 2> /dev/null") {|fd| fd.readlines}

While this doesn't:

IO.popen("/sbin/ifconfig 2> /dev/null") {|fd| fd.readlines}

ifconfig is located at /sbin/ifconfig.


Raphael Valyi added a comment - 05/Jan/08 01:53 PM

OK, sorry about my last comment: I was wrong the bug is fixed. I had a broken pipe error because my msmtprc file hadn't the correct rights anymore.
So it's fixed.

Stephen, I also see the same bug you mention on my Linux box with JRuby head. Still I believed the bug is different. So we should close this one and track yours elsewhere.
Isn't your bug exactly http://jira.codehaus.org/browse/JRUBY-1557 ? if not, then open an other JIRA.

Regards,

Raphaël Valyi.


Thomas E Enebo added a comment - 05/Jan/08 01:54 PM

Fixed per comment


Stephen Bannasch added a comment - 05/Jan/08 03:08 PM

Raphael, thanks for the comment.

Your right I think my bug is covered in JRUBY-1557 – though the bug is more general than just dealing with indirection.

I wanted you to be aware just in case some of the problems you were seeing related to those issues.