Net::SMTPSyntaxError (501 Sender syntax err$ Heroku

74 views
Skip to first unread message

sanoy

unread,
Aug 2, 2015, 2:11:52 AM8/2/15
to Ruby on Rails: Talk
Random issue with my ruby on rails application out of the blue. I'm getting a 501 error each time a user tries to submit the form. This error does not occur when I'm running the app locally, it only occurs when I push to Heroku.   

> heroku logs --tail(The error shows up below)

Net::SMTPSyntaxError (501 Sender syntax err$│
                  app/controllers/contact_controller.rb:38:$



    def tour_create
    @message = Message.new(params[:message])
    @message.type = "Tour"
    @message.save

    if @message.valid?
              UserMailer.tour_signup(@message).deliver
              flash[:notice] = "Thank you for your interest in  You'll receive an email from us confirming your participation in this Thursday's tour within 24- 48 hours."
              redirect_to("/tour/confirmed")
          else
            flash.now.alert = "Please fill all fields."
            render :tour_new
              end
      end

>usermailer.rb

    class UserMailer < ActionMailer::Base
      default from: "string"
    
    
      def tour_signup(message)
      @message = message
    
    mail(:to => message.email, 
    :cc => "string that is an email goes here", 
    :subject => message.first_name + ", Let's Tour This Wednesday"
    )
      end
    
      def orientation_signup(message, date)
        @message = message
        @date = date
    
        mail(:to => message.email, 
          :cc => "email", 
          :subject => message.first_name + ",string that gets sent to users inbox
        )
      end
    
      def ask_a_question(message)
      @message = message
    
    mail(:to => "emailstringgoes here", 
    :subject => message.first_name + " Has A Question"
    )
      end
    
      def trial_kickoff_confirmation_to_user(message, type)
      @message = message
      @date = message.event_time.strftime("%l:%M %P, on %A, %B %-d")
        @type = type
        type_subject = type.split.map(&:capitalize).join(' ')
    
    mail(:to => message.email,
    :subject => "Your #{type_subject} Has Been Scheduled!"
    )
      end
    
      def trial_kickoff_confirmation_to_hosts(message, type)
      @message = message
        @date = message.event_time.strftime("%l:%M %P, on %A, %B %-d")
        @type = type
        type_subject = type.split.map(&:capitalize).join(' ')
    
        if type == 'kick-off day'
          email = 'email'
        else
          email = 'email'
        end
    
    mail(:to => email, 
    :subject => "#{type_subject} for " + message.first_name + " " + message.last_name
    )  
      end
    
      def new_member_from_batchbook(member, password)
        @member = member
        @password = password
    
        mail(:to => @email, 
          #:cc => "emailgoes here string", 
          :subject => "#{@first_name}, finish your profile at string.com!"
        )
      end
    
    
      def member_import_notification message, status
        @message = message
        @status = status
        mail(
          :to => 'em...@string.com', 
          #:cc => "em...@string.com", 
          :subject => "#{@message['first_name']}, import to em...@string.com #{status}!"
        )
      end
    
      def no_new_member_notification
        mail(
          :to => 'em...@string.com', 
          #:cc => "em...@string.com", 
          :subject => "Import ran. No new members!"
        )
      end
    end

> .ruby-env

    bash -c 'echo "POSTMARK_API_TOKEN=`heroku config:get POSTMARK_API_TOKEN`" >> .env'
    bash -c 'echo "POSTMARK_SMTP_SERVER=`heroku config:get POSTMARK_SMTP_SERVER`" >> .env'
    bash -c 'echo "POSTMARK_INBOUND_ADDRESS=`heroku config:get POSTMARK_INBOUND_ADDRESS`" >> .env'

> Procfile
> web: bundle exec rails server -p 3000


Colin Law

unread,
Aug 2, 2015, 12:38:43 PM8/2/15
to Ruby on Rails: Talk
On 2 August 2015 at 06:29, sanoy <yonas.b...@gmail.com> wrote:
> Random issue with my ruby on rails application out of the blue. I'm getting
> a 501 error each time a user tries to submit the form. This error does not
> occur when I'm running the app locally, it only occurs when I push to
> Heroku.
>
>> heroku logs --tail(The error shows up below)
>
> Net::SMTPSyntaxError (501 Sender syntax err$│
> app/controllers/contact_controller.rb:38:$

Possibly one of the parameters for the email is invalid. I suggest
you log all the parameters (from, to, subject, etc) and see how they
look.

Colin
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/3c31b466-cf3c-464c-b81b-726d2a734202%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Donald Ziesig

unread,
Aug 2, 2015, 1:33:04 PM8/2/15
to rubyonra...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3c31b466-cf3c-464c-b81b-726d2a734202%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I had a similar problem (four years ago).  The problem involved the setup of the active mailer, (in my case with GoDaddy) that I never was able to resolve until I switched to gmail.  I can't remember exactly what the setup was, but it matched the values I found on the web for Rails to Gmail.

Good luck.

Don Z

tamouse pontiki

unread,
Aug 2, 2015, 2:07:42 PM8/2/15
to rubyonra...@googlegroups.com
On Sun, Aug 2, 2015 at 12:32 PM, Donald Ziesig <don...@ziesig.org> wrote:
On 08/02/2015 01:29 AM, sanoy wrote:
Random issue with my ruby on rails application out of the blue. I'm getting a 501 error each time a user tries to submit the form. This error does not occur when I'm running the app locally, it only occurs when I push to Heroku.   

> heroku logs --tail(The error shows up below)

Net::SMTPSyntaxError (501 Sender syntax err$│
                  app/controllers/contact_controller.rb:38:$

I can't say for sure, but this might be a problem that the MTA you're trying to use isn't configured or allowed to accept things from heroku, or without some further authentication. 
Message has been deleted

Matt Jones

unread,
Aug 3, 2015, 7:57:13 AM8/3/15
to Ruby on Rails: Talk


On Sunday, 2 August 2015 02:11:52 UTC-4, sanoy wrote:
Random issue with my ruby on rails application out of the blue. I'm getting a 501 error each time a user tries to submit the form. This error does not occur when I'm running the app locally, it only occurs when I push to Heroku.   

> heroku logs --tail(The error shows up below)

Net::SMTPSyntaxError (501 Sender syntax err$│
                  app/controllers/contact_controller.rb:38:$


>usermailer.rb

    class UserMailer < ActionMailer::Base
      default from: "string"


The error you're getting is the SMTP server rejecting your MAIL FROM command because of an invalid address. You've sanitized it to "string" here, so I can't say what's wrong with it. Make sure it doesn't contain any unwanted characters, and if it has dashes in it make sure they haven't been converted to Unicode ones by a "helpful" autocorrect.

You may want to reach out to Postmark's support and see if they can provide additional insight from their logs.

--Matt Jones 
Reply all
Reply to author
Forward
0 new messages