# Actionmailer - how to access request.env

**URL:** <https://www.ruby-forum.com/t/actionmailer-how-to-access-request-env/147600>\
**Category:** Rails\
**Created:** [September 3, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/actionmailer-how-to-access-request-env/147600 "2008-09-03T14:57:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [September 3, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/actionmailer-how-to-access-request-env/147600/1 "2008-09-03T14:57:25Z")

</div>

i need to access the host name (and probably the port) inside  
actionmailer.

i need to send a link to something in the public/images directory.

in any normal page, i can access this via the request.env variable, but  
it looks like this variable is not defined in actionmailer…

what i would like to do is have it send the correct link via email, no  
matter what server i run it from (my development machine, the test  
server, or the production server).

so on the my development server, it would spit out:

[http://localhost:3000/images/logo.gif](http://localhost:3000/images/logo.gif)

on the test server, it would spit out:

[http://www](http://www).:3000/images/logo.gif

and on the live one, it would spit out:

[http://www](http://www)..com/images/logo.gif

any ideas?

thanks!

---

<div class="post-metadata">

**Author:** ![spacechurro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d2c977/32.png) [@spacechurro](https://www.ruby-forum.com/u/spacechurro)\
**Post date:** [September 3, 2008, 3:36pm UTC](https://www.ruby-forum.com/t/actionmailer-how-to-access-request-env/147600/2 "2008-09-03T15:36:04Z")

</div>

just in case anyone is running into this same problem, i did a quick and  
dirty solution on this one…

i ended up sending request.host and request.port along with the function  
call…

i know… it’s ugly… but for right now, it works…
