PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Using actionmailer to send an email
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Using actionmailer to send an email

Réponse
 
LinkBack Outils de la discussion
Vieux 21/06/2008, 02h12   #1
APNelson.L
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Using actionmailer to send an email

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
  Réponse avec citation
Vieux 21/06/2008, 07h35   #2
Peña, Botp
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using actionmailer to send an email

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

  Réponse avec citation
Vieux 22/06/2008, 16h25   #3
ara.t.howard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Using actionmailer to send an email


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




  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h24.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09387 seconds with 11 queries