|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi, I was just wondering how i would write a ruby script to send an
email using the gmail smtp. Here is what I have so far: require 'rubygems' require 'action_mailer' class SimpleMailer < ActionMailer::Base def simple_message(recipient) from 'my_email@gmail.com' recipients recipient subject 'yay I just sent this' body 'hope this works' end end ActionMailer::Base.smtp_settings = { :address => 'smtp.gmail.com', :port => '25', :user_name => 'my_email@gmail.com', :password => 'my_password', :authentication => 'login' } SimpleMailer.deliver_simple_message('other_email@g mail.com') Unfortunately, when run I get these error messages: ruby mail.rb /usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0 Must issue a STARTTLS command first. z80sm1963933pyg.31 (Net::SMTPUnknownError) from /usr/local/lib/ruby/1.8/net/smtp.rb:582:in `auth_login' from /usr/local/lib/ruby/1.8/net/smtp.rb:686:in `critical' from /usr/local/lib/ruby/1.8/net/smtp.rb:581:in `auth_login' from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `__send__' from /usr/local/lib/ruby/1.8/net/smtp.rb:571:in `authenticate' from /usr/local/lib/ruby/1.8/net/smtp.rb:411:in `do_start' from /usr/local/lib/ruby/1.8/net/smtp.rb:378:in `start' from /usr/local/lib/ruby/1.8/net/smtp.rb:316:in `start' from /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/ action_mailer/base.rb:627:in `perform_delivery_smtp' from /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/ action_mailer/base.rb:508:in `__send__' from /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/ action_mailer/base.rb:508:in `deliver!' from /usr/local/lib/ruby/gems/1.8/gems/actionmailer-2.1.0/lib/ action_mailer/base.rb:383:in `method_missing' from mail.rb:15 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
From: APNelson.L [mailto:APNelson.L@gmail.com]=20
# ruby mail.rb # /usr/local/lib/ruby/1.8/net/smtp.rb:680:in `check_response': 530 5.7.0 # Must issue a STARTTLS command first. z80sm1963933pyg.31 this means that the server requires tls. check the rails list, they know better about actionmailer and its = plugins. kind regards -botp |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jun 20, 2008, at 7:13 PM, APNelson.L wrote: > Hi, I was just wondering how i would write a ruby script to send an > email using the gmail smtp. Here is what I have so far: > > require 'rubygems' > require 'action_mailer' > > class SimpleMailer < ActionMailer::Base > def simple_message(recipient) > from 'my_email@gmail.com' > recipients recipient > subject 'yay I just sent this' > body 'hope this works' > end > end > > ActionMailer::Base.smtp_settings = { :address => > 'smtp.gmail.com', :port => '25', :user_name => > 'my_email@gmail.com', :password => 'my_password', :authentication => > 'login' } > > SimpleMailer.deliver_simple_message('other_email@g mail.com') > you need to patch Net::SMTP to support tls, this is one of the easiest ways: http://drawohara.com/post/37908300/r...onmailer-gmail cheers. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama |
|
![]() |
| Outils de la discussion | |
|
|