Forum: Ruby on Rails mailer - from address not being set

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6d57db44c5a4e0721cc7f78cf0ce308a?d=identicon&s=25 Stephen Bartholomew (steveb)
on 2006-05-31 22:33
I'm having a weird problem with a mailer model.  The from address
doesn't seem to be set - my mail logs it shows that the sender address
is the default www@my.server.hostname and this causes the mail to
bounce.

The mailer code looks like this:

def thismail
  @subject    = "Subject"
  @recipients = "toemail@address.com"
  @from       = "myemail@address.com"
  # rest of code
end

The weird thing is, the development log shows the correct details...
---------
Sent mail:
 From: myemail@address.com
To: toemail@address.com
---------

Anyone come across this problem before?  I guess it could be the
server's mail setup but i thought i'd check just in case it's something
obvious/known :0)

Cheers,

Steve
6d57db44c5a4e0721cc7f78cf0ce308a?d=identicon&s=25 Stephen Bartholomew (steveb)
on 2006-05-31 23:19
Sorted. Entirely my stupidity.

Quick explaination:

The server wasn't complaining about the from address - it was
complaining about the fact that the server didn't have a reverse mapping
on the hostname it provided.

I didn't notice this at first because ActionMailer was suppressing any
errors it received from the smtp server.  Once i realised that the
environments/development.rb overrides environments.rb (duh!), i made
active mailer raise mail errors.  That gave me a nice error message.  I
then set up a reverse dns lookup for my dev server (something i should
have done ages ago) and all worked :0)

Steve

Stephen Bartholomew wrote:
> I'm having a weird problem with a mailer model.  The from address
> doesn't seem to be set - my mail logs it shows that the sender address
> is the default www@my.server.hostname and this causes the mail to
> bounce.
>
> The mailer code looks like this:
>
> def thismail
>   @subject    = "Subject"
>   @recipients = "toemail@address.com"
>   @from       = "myemail@address.com"
>   # rest of code
> end
>
> The weird thing is, the development log shows the correct details...
> ---------
> Sent mail:
>  From: myemail@address.com
> To: toemail@address.com
> ---------
>
> Anyone come across this problem before?  I guess it could be the
> server's mail setup but i thought i'd check just in case it's something
> obvious/known :0)
>
> Cheers,
>
> Steve
This topic is locked and can not be replied to.