GMailã®SMTPãµã¼ãã¼ã使ã£ã¦ã¡ã¼ã«ãéä¿¡ãããµã³ãã«
GMailã®SMTPãµã¼ãã¼ã«æ¥ç¶ããã¡ã¼ã«ãéä¿¡ãããµã³ãã«ã§ãã
- TMailå©ç¨ãã¦ã¡ã¼ã«ãä½æã
- ããã使ãã¨ãæ¥æ¬èªã¡ã¼ã«ãæ·»ä»ãã¡ã¤ã«ä»ãã¡ã¼ã«ãããã£ã¨ä½æã§ããã¿ããã§ãã
- ã¡ã¼ã«ã®éä¿¡ã¯Rubyä»å±ã®Net::SMTPã§ã
require 'rubygems' require 'tmail' require "tlsmail" # tmailã§ã¡ã¼ã«ãä½æ mail = TMail::Mail.new mail.to = '[email protected]' mail.from = '[email protected]' mail.subject = 'test mail' mail.date = Time.now mail.mime_version = '1.0' mail.set_content_type 'text', 'plain', {'charset'=>'iso-2022-jp'} mail.body = 'This is test mail.' # puts mail.to_s # ä½æãããã¡ã¼ã«ã確èªãããå ´åã¯ãã¡ãã # ã¡ã¼ã«ã¯Net::SMTPã§éä¿¡ã # gmailã¯TLSã«ããæå·åãå¿ è¦ãªã®ã§ãtlsmailãå©ç¨ããã # ã¾ããèªè¨¼ãå¿ é ã Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) Net::SMTP.start( "smtp.gmail.com", 587, "localhost.localdomain", "[email protected]", "<ãã¹ã¯ã¼ã>", "plain"){ |smtp| smtp.sendmail(mail.encoded, mail.from, mail.to) }
å®è¡ã«ã¯ä»¥ä¸ã®ã©ã¤ãã©ãªãå¿ è¦ã§ãã
$ gem install tmail $ gem install tlsmail