Forum: Ruby on Rails Help: Script isn't sending any email

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
cranberry (Guest)
on 2006-02-28 21:21
Hi,
I followed the directions to a 'T' from the following website:

http://wiki.rubyonrails.org/rails/pages/HowToSendE...

However, the script is dying because it says that the <%= first_name %>
value in my notifier view is nil.

here is my code:

Controller code (abridged):

def signup
userid = @session[:user].id
@user = User.find(userid)
@bill = Billing.find(userid)
@transaction = MyTransaction.new

## ....save some stuff to both billing and transaction ....

if ((@bill.save) && (@transaction.save))
Notifier::deliver_transaction_receipt_email(@user, @bill, @transaction)
end
end


Notifier model code:

def transaction_receipt_email( user, bill, transaction )
  # Email header info MUST be added here
  @recipients = user.email
  @from = "removed_email_address@domain.invalid"
  @subject = "Thank you for your payment"

  # Email body substitutions go here
  @body["first_name"] = user.first_name
  @body["last_name"] = user.last_name
  @body["transaction_id"] = transaction.id
  @body["amount"] = transaction.amount
  @body["account_balance"] = bill.current_account_balance
end

View Code:

<html>
<body>
Dear <%= @first_name %> <%= @last_name %>,

<p>We have successfully received your payment of $<%= @amount %>. Your
new
account balance is:<br>
<b>$<%= @current_account_balance %></b><br><br>
Transaction id: <%= transaction)id %><br>

<p>Please save this email receipt for your records.

</html>
</body>
This topic is locked and can not be replied to.