How do I use 'reply-to' with Action Mailer


#1

Hey there folks, I’m sure there is a stupidly easy answer for this, but
I can’t seem to find it. I’m building a site and I want a way for one
user to contact another. Simple enough. The problem lies in the fact I
want the email to ‘come from’ the user, and not from my system.

In my ActionMailer class if I do the following:
@from = “#{from_user.display_name} removed_email_address@domain.invalid

it works just fine. But I really want is:
@from = “#{from_user.display_name} removed_email_address@domain.invalid

If I do that though, the email never gets delivered.

So I guess my question is can someone tell me how to make this work
correctly? Of if I can’t get this to work, is there a way to set a
‘reply-to’ address so that when the user clicks reply in their email it
goes to ‘removed_email_address@domain.invalid’ and not to my notifier address?

Thanks in advance for the help.


#2

Hi Mark

You should be able to send the email using the second option you
described. Probably, the email server you’re using is setup to only send
emails from your domain, check the server logs to see why the email is
not delivered.

You can set the reply-to header like this:
@headers[‘Reply-to’] = from_user.reply_address

Cheers,

Cloves Carneiro Jr
http://www.ccjr.name

Mark B. wrote:

Hey there folks, I’m sure there is a stupidly easy answer for this, but
I can’t seem to find it. I’m building a site and I want a way for one
user to contact another. Simple enough. The problem lies in the fact I
want the email to ‘come from’ the user, and not from my system.

In my ActionMailer class if I do the following:
@from = “#{from_user.display_name} removed_email_address@domain.invalid

it works just fine. But I really want is:
@from = “#{from_user.display_name} removed_email_address@domain.invalid

If I do that though, the email never gets delivered.

So I guess my question is can someone tell me how to make this work
correctly? Of if I can’t get this to work, is there a way to set a
‘reply-to’ address so that when the user clicks reply in their email it
goes to ‘removed_email_address@domain.invalid’ and not to my notifier address?

Thanks in advance for the help.


#3

Thanks Cloves. That was exactly what I was looking for.
-Mark

Cloves Carneiro Jr wrote:

Hi Mark

You should be able to send the email using the second option you
described. Probably, the email server you’re using is setup to only send
emails from your domain, check the server logs to see why the email is
not delivered.

You can set the reply-to header like this:
@headers[‘Reply-to’] = from_user.reply_address

Cheers,

Cloves Carneiro Jr
http://www.ccjr.name