Forum: Ruby on Rails Unable to send mail

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
keerthi priya (Guest)
on 2012-09-18 16:36
(Received via mailing list)
Hi all i am trying to send mail but i could not send it and at the end
is redirecting to right page but mail is not receiving.

i got this in my log

Sent mail to mailid

Date: Tue, 18 Sep 2012 19:38:51 +0530
From: xxxx
To:  xxxx
Subject: fdfdsafsdafdsfsfsdafdsf
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

Redirected to http://localhost:3000/student/profile/776
Completed in 5696ms (DB: 3) | 302 Found

 UserMailer::deliver_email(sender, recipient_list,
params['email']['subject'], params['email']['message'])

class UserMailer < ActionMailer::Base
  def email(sender,recipients, subject, message)

    recipient_emails = (recipients.class == String) ? recipients.gsub('
','').split(',').compact : recipients.compact
    setup_email(sender, recipient_emails, subject, message)

  def setup_email(sender, emails, subject, message)"i am in SETUP"
    @from = sender
    @recipients = emails
    @subject = subject
    @sent_on =
    @body['message'] = message



ActionMailer::Base.smtp_settings = {
  :address => "",
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true,
  :user_name =>  "xxxx",
  :password => "xxxxx"

till def setup_email i am able to reach it but i am not receiving mail.

Avi (Guest)
on 2012-09-18 16:45
(Received via mailing list)
Can you check your spam folder in your mailbox ?
keerthi priya (Guest)
on 2012-09-18 16:56
(Received via mailing list)
yeah i am getting my mails not to my inbox . what should i do to get my
mail to inbox
Avi (Guest)
on 2012-09-18 17:01
(Received via mailing list)
What is your html content ?
Try not to use "&, # " in your html.
Hope it works.
keerthi priya (Guest)
on 2012-09-18 17:08
(Received via mailing list)
On Tue, Sep 18, 2012 at 8:30 PM, Avi <> wrote:

> What is your html content ?

> Try not to use "&, # " in your html.
i did not get this line
Avi (Guest)
on 2012-09-18 17:16
(Received via mailing list)
If there is an extra space, some symbols(which are spam) or any spam
the mail goes to the spam folder.
Try with a sentence(all words).
keerthi priya (Guest)
on 2012-09-18 17:25
(Received via mailing list)
I have sent a big text but still the same i am getting mail in spam
F3ce6b38fab69a0a8ba9226bc0b407d5?d=identicon&s=25 Walter D. (walterdavis)
on 2012-09-18 17:32
(Received via mailing list)
On Sep 18, 2012, at 11:24 AM, keerthi priya wrote:

> I have sent a big text but still the same i am getting mail in spam

You can't really do anything about spam filters from the sending side,
except to make your mail look less "spammy". Companies like MailChimp
and SendGrid spend millions to figure this out and to stay off of
blacklists, and it makes sense for them to invest like that, since they
are sending at scale. If getting your message into the in-box instead of
the spam-box is your goal, you might want to use SendGrid (since there's
a gem) and make sure that your message comes from a trusted

My own personal solution to this is to use my client's Exchange server
as the sender, since their clients are likely to have white-listed the
host in the past. Another pro tip is to use plain text mail only, avoid
HTML or attachments. There's more of an art than a science to this, and
it's a moving battle with the spam filters, I'm afraid.

Avi (Guest)
on 2012-09-18 17:37
(Received via mailing list)
Try adding :- :domain => "" in your mailer setting. &
you may modify your method
In user.rb :-
def email

In usermailer.rb :-

def email(user)
    @user = user
    mail(:to =>, :subject => "Welcome!!")
Avi (Guest)
on 2012-09-18 17:43
(Received via mailing list)
& may be you can try giving a meaningful subject to the email.
keerthi priya (Guest)
on 2012-09-18 17:53
(Received via mailing list)
i tried that also but still the same.
Avi (Guest)
on 2012-09-21 06:41
(Received via mailing list)
Not sure, because I was facing the same problem, & I removed spaces &
unnecessary symbols, & it worked fine for me.
This topic is locked and can not be replied to.