# Mail not sending

**URL:** <https://www.ruby-forum.com/t/mail-not-sending/128106>\
**Category:** Rails\
**Created:** [February 5, 2008, 2:31am UTC](https://www.ruby-forum.com/t/mail-not-sending/128106 "2008-02-05T02:31:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [February 5, 2008, 2:31am UTC](https://www.ruby-forum.com/t/mail-not-sending/128106/1 "2008-02-05T02:31:39Z")

</div>

I am having trouble with one of my notifications. For some reason it  
doesn’t seem to even try and send. I have notifications in other  
locations and they send just fine.

Here is the code that should call the notification:

```
if @post.save
  # We want to set the updated_at time if the post was saved
  # Updating the number of replies would be good too.
  Conversation.update(params[:conversation_id], { :updated_at =>

```

Time.now, :replies =\> replies })  
User.update(session[:user].id, { :num\_posts =\>  
(session[:user].num\_posts += 1) })

```
  conv_owner = Conversation.find(params[:conversation_id]).user_id
  owner_email = User.find(conv_owner).email
  Notifications.deliver_new_thread_post(owner_email,

```

params[:conversation\_id])

```
  if session[:conversation]
    redirect_to :controller => 'conversations', :action =>

```

‘show’, :id =\> session[:conversation]  
end

Here is the Notification method:

def new\_thread\_post(to, conversation\_id, sent\_at = Time.now)  
@subject = “Someone has posted to your thread”  
@body[‘conversation\_url’] = “[http://happyleper.com/conversations/](http://happyleper.com/conversations/)  
show/#{conversation\_id}”  
@recipients = to  
@from = ‘removed\_email\_address@domain.invalid’  
@sent\_on = sent\_at  
@headers = {}  
end

And the template:

There has been a reply to your thread at:

\<%= @conversation\_url %\>

When I make a thread post the code inside the if is run but I don’t  
see anything in the logs about the notification sending or failing.  
There is no postfix activity in /var/log/messages though so it would  
appear that it doesn’t run or dies before trying to send the email.

Any ideas?

Thanks.

---

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [February 5, 2008, 8:21pm UTC](https://www.ruby-forum.com/t/mail-not-sending/128106/2 "2008-02-05T20:21:51Z")

</div>

Thanks, I’ll toy around with it when I get home from work. Hopefully  
it is just a formatting issue. Mail sends fine when an account is  
created and when a user requests their log-in info.

Is there a way to turn on more verbose logging, specifically for  
notifications?

---

<div class="post-metadata">

**Author:** ![Glen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8c91f0/32.png) [@Glen](https://www.ruby-forum.com/u/Glen)\
**Post date:** [February 5, 2008, 6:00pm UTC](https://www.ruby-forum.com/t/mail-not-sending/128106/3 "2008-02-05T18:00:34Z")

</div>

On Mon, 2008-02-04 at 17:30 -0800, Glen wrote:

> Time.now, :replies =\> replies })  
> ‘show’, :id =\> session[:conversation]  
> show/#{conversation\_id}"
> 
> Any ideas?

* * *

are you configured to do e-mail in environment.rb ?

something like this?

# Include your app’s configuration here:

ActionMailer::Base.smtp\_settings = {  
:address =\> “My\_SMTP\_SERVER”,  
:port =\> 25,  
:domain =\> “[example.com](http://example.com)”  
#:user\_name =\> “removed\_email\_address@domain.invalid”,  
#:password =\> “mypass”,  
#:authentication =\> :login  
}

also, this doesn’t appear to be valid in your example…

@body[‘conversation\_url’] =   
“[http://happyleper.com/conversations/show/#{conversation\_id}](http://happyleper.com/conversations/show/#%7Bconversation_id%7D)”

Craig
