Reputation: 389
First time every trying to send an email from Rails. It seems to be working all expect the email never get delivered.
So here's the mailers class:
class UserMailer < ActionMailer::Base
default :from => "[email protected]"
def purchase_email(name, email, txid, itemname, code)
@name = name
@txId = txid
@itemName = itemname
@code = code
@email = email[1].gsub("%", "@")
mail(:to => @email, :subject => "Thank you for your purchase")
end
end
I call it in the controller here:
UserMailer.purchase_email(@name, @email, @txId, @itemName, @code).deliver
No errors, in fact I get a great feedback in the console:
Rendered user_mailer/purchase_email.html.erb (0.6ms)
Rendered user_mailer/purchase_email.text.erb (0.5ms)
Sent mail to [email protected] (25ms)
Date: Tue, 18 Oct 2011 14:40:03 -0400
From: [email protected]
To: [email protected]
Message-ID: <4e9dc803a34b2_1f83ffc0d5d19f4487bd@RossRankins-MacBook-Pro.local.mail>
Subject: Thank you for your purchase
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3
Date: Tue, 18 Oct 2011 14:40:03 -0400
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <4e9dc803a179e_1f83ffc0d5d19f448553@RossRankins-MacBook-Pro.local.mail>
-<snip>-
----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3
Date: Tue, 18 Oct 2011 14:40:03 -0400
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <4e9dc803a27fc_1f83ffc0d5d19f44864b@RossRankins-MacBook-Pro.local.mail>
<!DOCTYPE html>
<html>
-<snip>-
----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3--
So how do I start to diagnose the issue? Thanks!
Upvotes: 0
Views: 4242
Reputation: 831
By default Rails doesn't actually send emails in the development environment. If you want emails sent in development then you should follow the steps in this question:
Sending mail with Rails 3 in development environment
Upvotes: 4