# Envelopes using ActionMailer

**URL:** <https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742>\
**Category:** Rails\
**Created:** [May 27, 2008, 11:25am UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742 "2008-05-27T11:25:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 11:25am UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/1 "2008-05-27T11:25:55Z")

</div>

Hello,

I have been developing a web application using ROR (hosted on  
webricks/windows) which makes use of ActionMailer to send out mails to  
various mailing lists. Recently, we came across a use case which  
required that a particular user belonging to a mailing list should not  
be sent out the mails. He cannot be removed from the mailing list  
either. So I devised something like a negative subscriber list, where we  
remove the user after expanding the mailing lists. The downside here was  
that ‘outlook-client’ specific rules started breaking for other members  
of the mailing-list. I came to know that Actionmailer supports envelope  
viz., ‘‘Return-Path’’ header for reply-to component of e-mail. I was  
wondering if there is any way that we can specify such envelopes for TO  
and CC fields too.

I’m looking for something like what we have in sendmail of unix,

$sendmail removed\_email\_address@domain.invalid  
From:removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Subject: Test  
Hellows…

$

Any help would be of immense help to me. Please do let me know if you  
require any other information from my end.

Regards,  
Shankar.

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 11:30am UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/2 "2008-05-27T11:30:10Z")

</div>

On 27 May 2008, at 10:25, Shankar N. wrote:

> remove the user after expanding the mailing lists. The downside here  
> was  
> that ‘outlook-client’ specific rules started breaking for other  
> members  
> of the mailing-list. I came to know that Actionmailer supports  
> envelope  
> viz., ‘‘Return-Path’’ header for reply-to component of e-mail. I was  
> wondering if there is any way that we can specify such envelopes for  
> TO  
> and CC fields too.

You can set any header you want. In your mailer, set

@headers = {‘return-path’ =\> ‘removed\_email\_address@domain.invalid’, …}

Fred

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 11:49am UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/3 "2008-05-27T11:49:37Z")

</div>

Frederick C. wrote:

> On 27 May 2008, at 10:25, Shankar N. wrote:
> 
> > remove the user after expanding the mailing lists. The downside here  
> > was  
> > that ‘outlook-client’ specific rules started breaking for other  
> > members  
> > of the mailing-list. I came to know that Actionmailer supports  
> > envelope  
> > viz., ‘‘Return-Path’’ header for reply-to component of e-mail. I was  
> > wondering if there is any way that we can specify such envelopes for  
> > TO  
> > and CC fields too.
> 
> You can set any header you want. In your mailer, set
> 
> @headers = {‘return-path’ =\> ‘removed\_email\_address@domain.invalid’, …}
> 
> Fred

Fred,

Many thanks for your lightning-quick inputs on this. I had tried doing  
this with something like

@cc = [“removed\_email\_address@domain.invalid”,“removed\_email\_address@domain.invalid”]  
.  
.  
@headers = {‘cc’ =\> ‘removed\_email\_address@domain.invalid’}

The mails actually went through to removed\_email\_address@domain.invalid where as I wanted them to  
go only to removed\_email\_address@domain.invalid, removed\_email\_address@domain.invalid.

Please let me know if I am missing something gross here.

Regards,  
Shankar.

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 11:52am UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/4 "2008-05-27T11:52:01Z")

</div>

On 27 May 2008, at 10:49, Shankar N. wrote:

> them to  
> go only to removed\_email\_address@domain.invalid, removed\_email\_address@domain.invalid.

Well you’d have to say {‘cc’ =\> @cc} for this to have a chance of  
working.

Fred

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 12:09pm UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/5 "2008-05-27T12:09:14Z")

</div>

Frederick C. wrote:

> On 27 May 2008, at 10:49, Shankar N. wrote:  
> Well you’d have to say {‘cc’ =\> @cc} for this to have a chance of  
> working.
> 
> Fred

Ah! my mistake. If I understand this right, once we set the header  
fields, they would be ones to which the mails will be sent. What I want  
is something like sendmail where the recipients are different from what  
is indicated by the headers…

I’ll put it this way…

x,y ,z are members of the list ‘foo’ and:

@cc = [“removed\_email\_address@domain.invalid”,“removed\_email\_address@domain.invalid”,“removed\_email\_address@domain.invalid”]

Here z should not be sent a mail, and the cc fields for the mails sent  
to x and y should still read the cc fields as ‘foo’.

~Shankar.

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 12:26pm UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/6 "2008-05-27T12:26:09Z")

</div>

On 27 May 2008, at 11:09, Shankar N. wrote:

> want  
> is something like sendmail where the recipients are different from  
> what  
> is indicated by the headers…  
> ActionMailer doesn’t have anything for specifiying recipients as  
> arguments to sendmail. You’d have to do that yourself

Fred

---

<div class="post-metadata">

**Author:** ![shankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shankar](https://www.ruby-forum.com/u/shankar)\
**Post date:** [May 27, 2008, 12:36pm UTC](https://www.ruby-forum.com/t/envelopes-using-actionmailer/138742/7 "2008-05-27T12:36:39Z")

</div>

Frederick C. wrote:

> On 27 May 2008, at 11:09, Shankar N. wrote:
> 
> > want  
> > is something like sendmail where the recipients are different from  
> > what  
> > is indicated by the headers…  
> > ActionMailer doesn’t have anything for specifiying recipients as  
> > arguments to sendmail. You’d have to do that yourself
> 
> Fred

Okay. Given that the application is hosted on a windows server, I dont  
think its possible to implement sendmail in my case. Please correct me  
if I am missing something.

Thanks so much for all your help on this.

~Shankar.
