[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to send the email by Ruby script?

Wesley Chen

6/5/2009 4:51:00 PM

[Note: parts of this message were removed to make it a legal post.]

Hi, Guys,
I can read my sina.com email by the following code:
require 'net/pop'
Net::POP3.foreach('*pop3.sina.com.cn*', 110,
'my_email@sina.com', 'my_password' ) do |email|
hdr = email.header
if hdr =~ /\d+/
language = hdr.to_s
else
language = "INVALID"
end
puts language
end

I would like to send email by *smtp.sina.com.cn*, there is code on the net:

Net::SMTP.start('smtp.sina.com.cn',25) do |smtp|
smtp.send_message "hello", 'cjq_999@sina.com', ['cjq_999@sina.com']
end
But I get error message:
*e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530
Authentication required (Net::SMTPUnknownError)*

So, how can make it I can send the email by the ruby code?

Any suggestion would be quite appreciated.

Thanks.
Wesley Chen.

4 Answers

Mohit Sindhwani

6/5/2009 4:54:00 PM

0

Wesley Chen wrote:
> Hi, Guys,
> I can read my sina.com email by the following code:
> require 'net/pop'
> Net::POP3.foreach('*pop3.sina.com.cn*', 110,
> 'my_email@sina.com', 'my_password' ) do |email|
> hdr = email.header
> if hdr =~ /\d+/
> language = hdr.to_s
> else
> language = "INVALID"
> end
> puts language
> end
>
> I would like to send email by *smtp.sina.com.cn*, there is code on the net:
>
> Net::SMTP.start('smtp.sina.com.cn',25) do |smtp|
> smtp.send_message "hello", 'cjq_999@sina.com', ['cjq_999@sina.com']
> end
> But I get error message:
> *e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530
> Authentication required (Net::SMTPUnknownError)*
>
> So, how can make it I can send the email by the ruby code?
>
> Any suggestion would be quite appreciated.
>

I have a detailed example here:
http://notepad.onghu.com/2007/3/26/sending-email...
not sure if it helps.

Cheers,
Mohit.
6/6/2009 | 12:54 AM.


Wesley Chen

6/5/2009 5:09:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

Hi, Mohit,
Thank you very much, the code works great!

Thanks.
Wesley Chen.


On Sat, Jun 6, 2009 at 12:54 AM, Mohit Sindhwani <mo_mail@onghu.com> wrote:

> Wesley Chen wrote:
>
>> Hi, Guys,
>> I can read my sina.com email by the following code:
>> require 'net/pop'
>> Net::POP3.foreach('*pop3.sina.com.cn*', 110,
>> 'my_email@sina.com', 'my_password' ) do |email|
>> hdr = email.header
>> if hdr =~ /\d+/
>> language = hdr.to_s
>> else
>> language = "INVALID"
>> end
>> puts language
>> end
>>
>> I would like to send email by *smtp.sina.com.cn*, there is code on the
>> net:
>>
>> Net::SMTP.start('smtp.sina.com.cn',25) do |smtp|
>> smtp.send_message "hello", 'cjq_999@sina.com', ['cjq_999@sina.com']
>> end
>> But I get error message:
>> *e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530
>> Authentication required (Net::SMTPUnknownError)*
>>
>> So, how can make it I can send the email by the ruby code?
>>
>> Any suggestion would be quite appreciated.
>>
>>
>
> I have a detailed example here:
> http://notepad.onghu.com/2007/3/26/sending-email...
> not sure if it helps.
>
> Cheers,
> Mohit.
> 6/6/2009 | 12:54 AM.
>
>
>

Wesley Chen

6/5/2009 5:32:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

But do you know how to send the email with an attachment?

Thanks.
Wesley Chen.


On Sat, Jun 6, 2009 at 1:09 AM, Wesley Chen <cjq.999@gmail.com> wrote:

> Hi, Mohit,
> Thank you very much, the code works great!
>
> Thanks.
> Wesley Chen.
>
>
> On Sat, Jun 6, 2009 at 12:54 AM, Mohit Sindhwani <mo_mail@onghu.com>
> wrote:
>
> > Wesley Chen wrote:
> >
> >> Hi, Guys,
> >> I can read my sina.com email by the following code:
> >> require 'net/pop'
> >> Net::POP3.foreach('*pop3.sina.com.cn*', 110,
> >> 'my_email@sina.com', 'my_password' ) do |email|
> >> hdr = email.header
> >> if hdr =~ /\d+/
> >> language = hdr.to_s
> >> else
> >> language = "INVALID"
> >> end
> >> puts language
> >> end
> >>
> >> I would like to send email by *smtp.sina.com.cn*, there is code on the
> >> net:
> >>
> >> Net::SMTP.start('smtp.sina.com.cn',25) do |smtp|
> >> smtp.send_message "hello", 'cjq_999@sina.com', ['cjq_999@sina.com']
> >> end
> >> But I get error message:
> >> *e:/ruby/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530
> >> Authentication required (Net::SMTPUnknownError)*
> >>
> >> So, how can make it I can send the email by the ruby code?
> >>
> >> Any suggestion would be quite appreciated.
> >>
> >>
> >
> > I have a detailed example here:
> > http://notepad.onghu.com/2007/3/26/sending-email...
> > not sure if it helps.
> >
> > Cheers,
> > Mohit.
> > 6/6/2009 | 12:54 AM.
> >
> >
> >
>

Mohit Sindhwani

6/5/2009 6:08:00 PM

0

Wesley Chen wrote:
> But do you know how to send the email with an attachment?
>
> Thanks.
> Wesley Chen.
>

I haven't needed to, but a Google search should find you quite a few hits.

Cheers,
Mohit.
6/6/2009 | 2:07 AM.