2009-04-02 7 views
8

मैं चाहता हूं कि एसएसटीपी पर एसएसटीपी पर मेरी रूबी स्क्रिप्ट से ईमेल भेजना है।एसएसएल के साथ smtp पर रूबी के साथ मेल कैसे भेजें (रेल के साथ नहीं, जीमेल के लिए कोई टीएलएस नहीं)

मुझे केवल रेल से, या जीमेल के लिए टीएलएस के उदाहरण मिलते हैं।

मैंने लोगों को रूबी 1.8.5 के साथ एसएमटीपीएस समर्थन के बारे में बात करते हुए पाया, लेकिन libdoc इसका उल्लेख नहीं करता है।

पोर्ट 465 पर एसएसटीपी के साथ एसएमटीपी पर मेल भेजने का उदाहरण वाला कोई भी व्यक्ति?

ruby -v 
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] 

उत्तर

0

आप शायद पहले से ही एसएसएल हिस्सा है, जो बॉक्स से बाहर का समर्थन किया जाना प्रतीत नहीं होता है के बारे में Net::SMTP standard library

के बारे में पता है, मैंने पाया संभव संकेत के एक जोड़े:

+०१२३५१६४१०६
+0

मैंने पहले से ही उन उदाहरणों का प्रयास किया है, और जीमेल के साथ बहुत अच्छा काम किया है, लेकिन मैं उन्हें अपने आईएसपी खातों पर एसएसएल पर नियमित एसएमटीपी के साथ काम नहीं कर सकता। –

0

केवल दिलचस्प बात यह है कि मैं कार्यक्रम संबंधी ईमेल में के बारे में सुना हाल ही में Lamson है:

: http://lamsonproject.org/

यह अजगर, नहीं रूबी है, लेकिन अगर आप चाहते हैं आप रूबी से अजगर कॉल कर सकते हैं (http://www.goto.info.waseda.ac.jp/~fukusima/ruby/python-e.html यहाँ एक ही रास्ता है)

0

आप mailsend (http://www.muquit.com/muquit/software/mailsend/mailsend.html) की तरह एक तीसरी पार्टी खुला स्रोत कमांड लाइन प्रोग्राम का उपयोग आप के लिए अपने गंदे काम करने के लिए कर सकता है। बस उस प्रारूप में कुछ आउटपुट पाइप करें जो अपेक्षा करता है।

3

कैसे टट्टू के बारे में?
मणि टट्टू स्थापित करें।
http://github.com/adamwiggins/pony/tree/master
या मुझे आपका प्रश्न समझ में नहीं आया?

मुझे आशा है कि यह आपकी मदद कर।
धन्यवाद
tknv/

0

आप इस तरह आप बंदर-पैच नेट कर सकते हैं टीएलएस के बजाय एसएसएल :: एसएमटीपी का उपयोग करने के हों:

require "openssl" 
require "net/smtp" 

Net::SMTP.class_eval do 

    def self.start(address, port = nil, 
        helo = 'localhost.localdomain', 
        user = nil, secret = nil, authtype = nil, use_tls = false, 
        use_ssl = false, &block) # :yield: smtp 
    new(address, port).start(helo, user, secret, authtype, use_tls, use_ssl, &block) 
    end 

    def start(helo = 'localhost.localdomain', 
      user = nil, secret = nil, authtype = nil, use_tls = false, use_ssl = false) # :yield: smtp 
    start_method = use_tls ? :do_tls_start : use_ssl ? :do_ssl_start : :do_start 
    if block_given? 
     begin 
     send start_method, helo, user, secret, authtype 
     return yield(self) 
     ensure 
     do_finish 
     end 
    else 
     send start_method, helo, user, secret, authtype 
     return self 
    end 
    end 

    private 

    def do_tls_start(helodomain, user, secret, authtype) 
    raise IOError, 'SMTP session already started' if @started 

    if VERSION == '1.8.6' 
     check_auth_args user, secret, authtype if user or secret 
    elsif VERSION == '1.8.7' 
     check_auth_args user, secret 
    end 

    sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) } 
    @socket = Net::InternetMessageIO.new(sock) 
    @socket.read_timeout = 60 #@read_timeout 
    @socket.debug_output = STDERR #@debug_output 

    check_response(critical { recv_response() }) 
    do_helo(helodomain) 

    raise 'openssl library not installed' unless defined?(OpenSSL) 
    starttls 
    ssl = OpenSSL::SSL::SSLSocket.new(sock) 
    ssl.sync_close = true 
    ssl.connect 
    @socket = Net::InternetMessageIO.new(ssl) 
    @socket.read_timeout = 60 #@read_timeout 
    @socket.debug_output = STDERR #@debug_output 
    do_helo(helodomain) 

    authenticate user, secret, authtype if user 
    @started = true 
    ensure 
    unless @started 
     # authentication failed, cancel connection. 
     @socket.close if not @started and @socket and not @socket.closed? 
     @socket = nil 
    end 
    end 

    def do_ssl_start(helodomain, user, secret, authtype) 
    raise IOError, 'SMTP session already started' if @started 

    if VERSION == '1.8.6' 
     check_auth_args user, secret, authtype if user or secret 
    elsif VERSION == '1.8.7' 
     check_auth_args user, secret 
    end 

    sock = timeout(@open_timeout) { TCPSocket.open(@address, @port) } 
    raise 'openssl library not installed' unless defined?(OpenSSL) 
    ssl = OpenSSL::SSL::SSLSocket.new(sock) 
    ssl.sync_close = true 
    ssl.connect 
    @socket = Net::InternetMessageIO.new(ssl) 
    @socket.read_timeout = 60 #@read_timeout 
    @socket.debug_output = STDERR #@debug_output 

    check_response(critical { recv_response() }) 
    do_helo(helodomain) 

    do_helo(helodomain) 

    authenticate user, secret, authtype if user 
    @started = true 
    ensure 
    unless @started 
     # authentication failed, cancel connection. 
     @socket.close if not @started and @socket and not @socket.closed? 
     @socket = nil 
    end 
    end 

    def do_helo(helodomain) 
    begin 
     if @esmtp 
     ehlo helodomain 
     else 
     helo helodomain 
     end 
    rescue Net::ProtocolError 
     if @esmtp 
     @esmtp = false 
     @error_occured = false 
     retry 
     end 
     raise 
    end 
    end 

    def starttls 
    getok('STARTTLS') 
    end 

    def quit 
    begin 
     getok('QUIT') 
    rescue EOFError, OpenSSL::SSL::SSLError 
    end 
    end 
end 

देखें http://github.com/collectiveidea/action_mailer_optional_tls/blob/master/lib/smtp_tls.rb

9

मैं के साथ इस मुद्दे को हल नीचे यह कॉन्फ़िगरेशन:

config.action_mailer.perform_deliveries = true 
config.action_mailer.raise_delivery_errors = false 
config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
    :address    => 'mail.domain.com', 
    :port     => '465', 
    :domain    => 'yourdomain.com', 
    :user_name   => '[email protected]', 
    :password    => 'yourpassword', 
    :authentication  => :login, 
    :ssl     => true, 
    :openssl_verify_mode => 'none' #Use this because ssl is activated but we have no certificate installed. So clients need to confirm to use the untrusted url. 
} 

यह मेरे लिए बहुत अच्छा काम करता है।

+1

gitlab/मेल सूचनाओं के साथ लड़ रहा था -: ssl => true मेरे लिए काम किया। –

+0

मेल जेम के लिए README.md दस्तावेज़ (https://github.com/mikel/mail#getting-emails-from-a-pop-server) वास्तव में पुराना है, इसलिए ': enable_ssl => true' अब काम नहीं करता है, बजाय का उपयोग ': ssl => TRUE', क्या एक दर्द 〒_〒 – DiveInto

संबंधित मुद्दे