<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eXpand yOur cReativity &#187; google apps</title>
	<atom:link href="http://blog.bhushangahire.net/tag/google-apps/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 07:17:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>How to use Google Apps mail configuration with rails application.</title>
		<link>http://blog.bhushangahire.net/2009/07/22/how-to-use-google-apps-mail-configuration-with-rails-application/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-use-google-apps-mail-configuration-with-rails-application</link>
		<comments>http://blog.bhushangahire.net/2009/07/22/how-to-use-google-apps-mail-configuration-with-rails-application/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 10:05:21 +0000</pubDate>
		<dc:creator>Bhushan Ahire</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[google apps]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=134</guid>
		<description><![CDATA[I am using google apps for my domain www.bhushangahire.com For one of my rails application I am using this domain mail account setup for sending mails. But I am not able to send the mail with the default smtp setings we use for sending mail. So I search on net and I found the Goggle [...]]]></description>
			<content:encoded><![CDATA[<div id="content"><!--single.php--></p>
<p><!--loop--></p>
<p><!--post title--></p>
<div class="post-meta-top">
<div class="clearboth"></div>
<p><!--content with more link--></p>
<p>I am using google apps for my domain <strong>www.bhushangahire.com</strong></p>
<p>For one of my rails application I am using this domain mail account setup for sending mails.</p>
<p>But I am not able to send the mail with the default smtp setings we use for sending mail.</p>
<p>So I search on net and I found the Goggle Apps consider its in different way. Which is TLS ans SSH service, which is not by default comes with the Action mailler.</p>
<p class="vspace"><span class="wikiword">ActionMailer</span> can’t send emails using <span class="wikiword">GMail</span> out of the box. To add this functionality do the following configuration in your rails application:</p>
<ol>
<li>Create the file <strong><code>lib/smtp_tls.rb</code></strong>
<div class="code">
<pre>require "openssl"
require "net/smtp"

Net::SMTP.class_eval do
private
def do_start(helodomain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
check_auth_args user, secret, authtype if user or secret

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

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
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
rescue OpenSSL::SSL::SSLError
end
end
end</pre>
</div>
</li>
<li>Add the following lines to <strong><code>config/environment.rb</code></strong> and replace the values with the appropriate username and password:
<div class="code">
<pre>require 'smtp_tls'
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.server_settings = {
:address =&gt; "smtp.gmail.com",
:port =&gt; 587,
:domain =&gt; "mydomain.com",
:authentication =&gt; :plain,
:user_name =&gt; "username@mydomain.com",
:password =&gt; "password"
}</pre>
</div>
<p><strong><sup>*</sup>Note:</strong>To work your domain with <strong>“mydomain.com”</strong> you have to configure your <strong>MX records</strong> to work Gmail mail sending functionality out of box.</p>
<p>Else you can use a temporary address <strong>@mydomain.com.test-google-a.com</strong>, I have not tested with this as I have already configure my <strong>MX records</strong>.</p>
<p>You can get more information on changing <strong><a href="http://www.google.com/support/a/bin/answer.py?answer=33352">http://www.google.com/support/a/bin/answer.py?answer=33352</a></strong>.</p>
<p>Hope this information is useful to you. <img class="wp-smiley" src="http://blogs.circlesource.com/wp-includes/images/smilies/icon_wink.gif" alt=";-)" /></li>
</ol>
<p><!--for paginate posts--></p>
<p><!--Post Meta--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2009/07/22/how-to-use-google-apps-mail-configuration-with-rails-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

