Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.
Ruby Newbee wrote:
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.
Have fun!
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.open_message_stream('from_addr', [to_addr]) do |f|
f.puts 'From: shabbir@g4ef.com'
f.puts 'To: pradeep@g4ef.com'
f.puts 'Subject: test message'
f.puts 'This is a test message.'
end
end
Derek
--
Posted via http://www.ruby-forum.com/\.
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.
To add to your confusion on what to use, I'd suggest you use the Mail gem, which is TMail's successor: GitHub - mikel/mail: A Really Ruby Mail Library
I'm betting it will become part of the Ruby standard library, but who knows. I think it should anyways.
- Ehsan
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/
Ruby Newbee wrote:
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.Have fun!
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.open_message_stream('from_addr', [to_addr]) do |f|
f.puts 'From: shabbir@g4ef.com'
f.puts 'To: pradeep@g4ef.com'
f.puts 'Subject: test message'
f.puts 'This is a test message.'
end
endDerek
Take a look at tmail also.
It goes without saying that you should follow the law. In the United
States ( I don't know about other countries' laws)
We have the CAN SPAM act.
Make sure you follow it, because people who spam should be
#{insert_your_patent_of_punishment}
Andrew McElroy
On Thu, Dec 31, 2009 at 9:43 PM, Derek Smith <derekbellnersmith@yahoo.com> wrote:
--
Posted via http://www.ruby-forum.com/\.
Hi
You can also use ActionMailer.
see below:
http://am.rubyonrails.org/
---
Ayumu AIZAWA
twitter.com/ayumin
Thanks, that works.
But from syntax point to see, what's Net::SMTP.start('smtp.example.com', 25)?
why it can accept a block as argument?
what's the content of "smtp"?
why "smtp" (it seems being taken from God) has the method of
"open_message_stream"?
and what other methods it does also have?
Sorry for my newbie questions.
Regards,
Jenn.
On Fri, Jan 1, 2010 at 11:43 AM, Derek Smith <derekbellnersmith@yahoo.com> wrote:
Ruby Newbee wrote:
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.Have fun!
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.open_message_stream('from_addr', [to_addr]) do |f|
f.puts 'From: shabbir@g4ef.com'
f.puts 'To: pradeep@g4ef.com'
f.puts 'Subject: test message'
f.puts 'This is a test message.'
end
end
Hi
You can also use ActionMailer.
ActionMailer uses tmail
see below:
http://am.rubyonrails.org/
Andrew McElroy
On Thu, Dec 31, 2009 at 11:12 PM, Ayumu Aizawa <ayumu.aizawa@gmail.com> wrote:
---
Ayumu AIZAWA
twitter.com/ayumin
Ruby Newbee wrote:
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.Have fun!
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.open_message_stream('from_addr', [to_addr]) do |f|
f.puts 'From: shabbir@g4ef.com'
f.puts 'To: pradeep@g4ef.com'
f.puts 'Subject: test message'
f.puts 'This is a test message.'
end
endThanks, that works.
But from syntax point to see, what's Net::SMTP.start('smtp.example.com', 25)?
why it can accept a block as argument?
Because it the #start method was written that way.
The reason, I imagine, is to provide some failure resistance: If a code gets exited, the environment gets "reset" (DB connections get closed, files written to disk, etc).
what's the content of "smtp"?
Take a look at it with smtp.inspect in the block.
why "smtp" (it seems being taken from God) has the method of
"open_message_stream"?
smtp is a block variable (the | at each side tells Ruby that).
Since smtp is a block variable in a Net::SMTP block, it gains access to the methods Net::SMTP provides to its blocks.
You could've named the block variable |s| or |richard|, and the methods would still work.
It makes life easier if the variable's name tells you what it does when you read the name.
and what other methods it does also have?
smtp.methods
Sorry for my newbie questions.
A handy tip I use when I explore something new:
You can #inspect objects or check its #methods in Ruby, and #sort the output. A simple "puts Class.methods" shows you, in the terminal / on the command line which methods the class Class has. "puts Class.methods.sort" sorts the output for you (alphabetically in this case).
On 01.01.2010 07:06, Ruby Newbee wrote:
On Fri, Jan 1, 2010 at 11:43 AM, Derek Smith > <derekbellnersmith@yahoo.com> wrote:
--
Phillip Gawlowski
Thanks Phillip.
Can you kindly tell me how to write that a method?
I know something like:
class Myclass
def myfunc a,b,c
do_something_with a,b,c
end
end
x= Myclass.new
x.myfunc(1,2,3)
but I dont know how to write a method which accepts a block (like the
above smtp one).
THanks.
Jenn.
On Fri, Jan 1, 2010 at 2:16 PM, Phillip Gawlowski <pg@thimian.com> wrote:
On 01.01.2010 07:06, Ruby Newbee wrote:
On Fri, Jan 1, 2010 at 11:43 AM, Derek Smith >> <derekbellnersmith@yahoo.com> wrote:
Ruby Newbee wrote:
Hello,
I need a module for sending emails.
Could you show me where I can find it and what's the syntax?
Thanks.Have fun!
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.open_message_stream('from_addr', [to_addr]) do |f|
f.puts 'From: shabbir@g4ef.com'
f.puts 'To: pradeep@g4ef.com'
f.puts 'Subject: test message'
f.puts 'This is a test message.'
end
endThanks, that works.
But from syntax point to see, what's Net::SMTP.start('smtp.example.com',
25)?
why it can accept a block as argument?Because it the #start method was written that way.
The reason, I imagine, is to provide some failure resistance: If a code gets
exited, the environment gets "reset" (DB connections get closed, files
written to disk, etc).
Thanks Phillip.
Can you kindly tell me how to write that a method?
Not me directly, no, but I found this:
http://blog.codahale.com/2005/11/24/a-ruby-howto-writing-a-method-that-uses-code-blocks/
I know something like:
class Myclass
def myfunc a,b,c
do_something_with a,b,c
end
endx= Myclass.new
x.myfunc(1,2,3)but I dont know how to write a method which accepts a block (like the
above smtp one).
THanks.
It's not much different than that.
def block
yield
end
is a simple block method already. Not terribly useful, but it's the foundation to build from.
On 01.01.2010 07:26, Ruby Newbee wrote:
--
Phillip Gawlowski
Thanks.
I really like that!
On Fri, Jan 1, 2010 at 2:33 PM, Phillip Gawlowski <pg@thimian.com> wrote:
On 01.01.2010 07:26, Ruby Newbee wrote:
Thanks Phillip.
Can you kindly tell me how to write that a method?Not me directly, no, but I found this:
http://blog.codahale.com/2005/11/24/a-ruby-howto-writing-a-method-that-uses-code-blocks/