I am trying to send mail using sendmail settings but i am not receiving the mail I can see the mail sent in development log.
config/application.rb
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t'
}
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
mailers/Notifier.rb
class Notifier < ActionMailer::Base
default :from => "deepika#xxx.com"
def welcome_email
mail(:to => "deepika#xxx.com", :subject => "Welcome to My Site test mail")
end
end
And i am calling Notifier.welcome_email.deliver from index method.
I can see log
Sent mail to deepika#xxx.com (339ms)
Date: Wed, 10 Apr 2013 15:16:33 +0530
From: deepika#xxx.com
To: deepika#xxx.com
Message-ID: <516534f983356_30f3262c7c84610d2#cybage-virtual-machine.mail>
Subject: Welcome to My Site test mail
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Thanks for joining and have a great day!</p>
But i am not receiving mail.
when i do service sendmail status i am getting
MSP: is run via cron (20m)
MTA: 123995 /usr/sbin/sendmail-mta -Am -L sm-mta -bd -q10m
UID PID PPID C STIME TTY TIME CMD
root 123995 1 0 15:36 ? 00:00:00 sendmail: MTA: accepting connections
Daemon Status: (process 132996) Queue runner
Current number of children: 1
QueueDir free disk space (in blocks): 285222800
Load average: 1
Child Process 139595 Status: accepting connections
Child Process 144035 Status: console socket child
QUE: Same as MTA
Also when i do vi /var/mail/root, I am getting following
This is a MIME-encapsulated message
--r3A9kDux012954.1365587178/cybage-virtual-machine.cybage.com
The original message was received at Wed, 10 Apr 2013 15:02:21 +0530
from localhost
with id r3Adsdsd9WLU5012559
----- The following addresses had permanent fatal errors -----
<deepika#xxx.com>
(reason: Client was not authenticated)
----- Transcript of session follows -----
... while talking to mail.xxx.com.:
>>> MAIL From:<> SIZE=268814
<<< 530 5.7.1 Client was not authenticated
Service unavailable
Can you please tell me what is the reason behind not receiving mail.
Related
Following the hartle tutorial here: https://www.learnenough.com/action-cable-tutorial#sec-upgrading_to_action_cable
When I get to Step 4, adding ActionCable the chat messages are not transmitted and I get the error:
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" IS NULL LIMIT ? [["LIMIT", 1]]
An unauthorized connection attempt was rejected
here are the relevant files:
room_channel.rb:
class RoomChannel < ApplicationCable::Channel
def subscribed
stream_from "room_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
messages controller:
class MessagesController < ApplicationController
before_action :logged_in_user
before_action :get_messages
def index
end
def create
message = current_user.messages.build(message_params)
if message.save
ActionCable.server.broadcast 'room_channel',
message: render_message(message)
message.mentions.each do |mention|
ActionCable.server.broadcast "room_channel_user_# {mention.id}",
mention: true
end
end
end
private
def get_messages
#messages = Message.for_display
#message = current_user.messages.build
end
def message_params
params.require(:message).permit(:content)
end
def render_message(message)
render(partial: 'message', locals: { message: message })
end
end
room.coffee:
App.room = App.cable.subscriptions.create "RoomChannel",
connected: ->
# Called when the subscription is ready for use on the server
disconnected: ->
# Called when the subscription has been terminated by the server
received: (data) ->
# Called when there's incoming data on the websocket for this channel
alert data.content
routes.rb:
Rails.application.routes.draw do
root 'messages#index'
resources :users
resources :messages
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
mount ActionCable.server, at: '/cable'
end
The reference branch works fine on my machine, but I can't get my tutorial branch to use AC.
Update:
Skipping down to Section 5 of the tutorial, I added connection.rb, which had been blank in the tutorial's beginning repo as follows:
connection.rb:
module ApplicationCable
class Connection < ActionCable::Connection::Base
include SessionsHelper
identified_by :message_user
def connect
self.message_user = find_verified_user
end
private
def find_verified_user
if logged_in?
current_user
else
reject_unauthorized_connection
end
end
end
end
And broadcasting seems to work in one direction. I have two tabs open. but only one works to broadcast messages. In the other, the console shows this error:
Error: Existing connection must be closed before opening action_cable.self-17ebe4af84895fa064a951f57476799066237d7bb5dc4dc351a8b01cca19cce9.js:231:19
Connection.prototype.open
http://localhost:3000/assets/action_cable.self-17ebe4af84895fa064a951f57476799066237d7bb5dc4dc351a8b01cca19cce9.js:231:19
bind/<
http://localhost:3000/assets/action_cable.self-17ebe4af84895fa064a951f57476799066237d7bb5dc4dc351a8b01cca19cce9.js:201:60
In the logs, with the above connection.rb, the search for null user is gone, showing this:
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
Registered connection (Z2lkOi8vY2hhdC1hcHAvVXNlci8x)
RoomChannel is transmitting the subscription confirmation
RoomChannel is streaming from room_channel
Started GET "/cable" for ::1 at 2018-12-29 08:04:31 -0500
Started GET "/cable/" [WebSocket] for ::1 at 2018-12-29 08:04:31 -0500
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: keep-alive, Upgrade, HTTP_UPGRADE: websocket)
when testing proxy in mobicents, mobicents cannot forward bye message to the other one.
when one user send bye, it just receives 481 and the other user remains in talking.
Such exception only occurs when call duration >= 10s.
and i can see that sip application session is closed before user send bye. i dont konw how to avoid this.
please help me !!!
below is my test code:
#Override
protected void doInvite(SipServletRequest request) throws ServletException, IOException {
List<SipURI> forks = new ArrayList<SipURI>();
SipURI toURI = (SipURI) request.getTo().getURI();
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
forks.add( sipFactory.createSipURI(toURI.getUser(),"192.168.4.160:11180") );
forks.add( sipFactory.createSipURI("9988003","192.168.4.30:5080") );
//request.getProxy().setParallel(true);
List<ProxyBranch> branches = request.getProxy().createProxyBranches( forks );
for(ProxyBranch branch: branches){
branch.setRecordRoute(true);
}
request.getProxy().startProxy();
}
and i get an exception in my log:
org.mobicents.servlet.sip.core.DispatcherException: Cannot find the corresponding sip application session to this subsequent request BYE sip:9988002#192.168.4.160:11180;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.4.204:11180;rport=11180;branch=z9hG4bKBH36Ht963rXeB;received=192.168.4.204
Max-Forwards: 70
From: "Extension 9988001" <sip:9988001#192.168.4.204>;tag=KtgZ29USetpNj
To: <sip:9988002#192.168.4.89>;tag=vN8t8Xm8yXg2K
Call-ID: 0e0bee76-943b-1234-4ba8-000c29680286
CSeq: 91266548 BYE
Contact: <sip:mod_sofia#192.168.4.204:11180>
User-Agent: FreeSWITCH-mod_sofia/1.2.23~64bit
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REGISTER,REFER,NOTIFY
Supported: timer,path,replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0
with the following popped route header <sip:192.168.4.89:5060;transport=udp;as=ded31d5f-500e-4c2d-84bb-370065d85c87;appname=1180947b;proxy=true;app_id=7599adf4;lr>, it may already have been invalidated or timed out
at org.mobicents.servlet.sip.core.dispatchers.SubsequentRequestDispatcher.dispatchMessage(SubsequentRequestDispatcher.java:248)
at org.mobicents.servlet.sip.core.SipApplicationDispatcherImpl.processRequest(SipApplicationDispatcherImpl.java:861)
at gov.nist.javax.sip.EventScanner.deliverRequestEvent(EventScanner.java:250)
at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:146)
at gov.nist.javax.sip.SipProviderImpl.handleEvent(SipProviderImpl.java:185)
at gov.nist.javax.sip.DialogFilter.processRequest(DialogFilter.java:1324)
at gov.nist.javax.sip.stack.SIPServerTransactionImpl.processRequest(SIPServerTransactionImpl.java:811)
at gov.nist.javax.sip.stack.UDPMessageChannel.processMessage(UDPMessageChannel.java:578)
at gov.nist.javax.sip.stack.UDPMessageChannel.processIncomingDataPacket(UDPMessageChannel.java:524)
at gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:319)
at java.lang.Thread.run(Thread.java:722)
Is this happening only for calls whose duration is > 3 minutes ?
The sip servlets specification defines the default duration for sip session to be 3 minutes. You can modify it in the sip.xml session-timeout attribute or programatically in your app.
I try to test schema integration with rails application. I used my personal Gmail account to configure SMTP :
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'gmail.com',
user_name: 'XXXX#gmail.com',
password: 'XXXX',
authentication: 'plain',
enable_starttls_auto: true
}
I test to send it to my own account. But it's seems that doesn't work..
I test with example code from :
PS : The mail pass validation
Thank you
EDIT : Header of my mail
Return-Path: <XXX#gmail.com>
Received: from gmail.com (84-74-24-22.dclient.hispeed.ch. [84.74.24.22])
by mx.google.com with ESMTPSA id m8sm9364668eeg.11.2014.04.23.13.34.35
for <XXX#gmail.com>
(version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
Wed, 23 Apr 2014 13:34:35 -0700 (PDT)
Date: Wed, 23 Apr 2014 22:34:34 +0200
From: XXX#gmail.com
To: XXX#gmail.com
Message-ID: <535823da92e7c_3d223ffc2442dbe093598#WS-39.local.mail>
Subject: =?UTF-8?Q?Merci_d'avoir_command=C3=A9_!?=
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_535823da916a1_3d223ffc2442dbe0934a9";
charset=UTF-8
Content-Transfer-Encoding: 7bit
I have a functionality wherein i have to upload a large number of records from a csv file. If any one of the records is invalid, no data should be uploaded. A csv file with errors against the invalid records needs to be sent to the user who uploaded the data. I am using rails (3.2), sidekiq (2.16.1) and mysql.
All the mails (devise and custom) mails are delivered and i receive them in my gmail inbox. The above functionality worked fine before being shifted to sidekiq.
User model
#works n gets delivered in inbox
Notifier.send_welcome_mail(self).deliver
Sidekiq Worker
class UploadWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform(user_id, inspection_id)
user = User.find(user_id)
inspection = Inspection.find(inspection_id)
err = false
#check if all data is valid and upload if valid
#
...
#shows in development log but doesnt get delivered in inbox.
Notifier.delay.upload_success(user, inspection) if err
Notifier.delay.upload_failed(user, inspection) unless err
end
end
development log
Sent mail to someone#gmail.com (142ms)
Date: Wed, 13 Nov 2013 17:24:25 +0530
To: someone#gmail.com
Message-ID: <5283687179a92_203f59f273e3#gmail.mail>
Subject: ["someone#gmail.com"] Upload failed
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
sidekiq log
2013-11-13T13:21:20Z 10064 TID-1n41gu UploadWorker JID-2d2c930601caf6a62c86e142 INFO: start
2013-11-13T13:22:13Z 10064 TID-1n41gu UploadWorker JID-2d2c930601caf6a62c86e142 INFO: done: 52.858 sec
2013-11-13T13:22:13Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-bcae8ea4974ecfe280e411bd INFO: start
2013-11-13T13:22:14Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-bcae8ea4974ecfe280e411bd INFO: done: 0.858 sec
2013-11-13T13:23:51Z 10064 TID-1n41gu UploadWorker JID-03fe3dee40f6390f5cec1d93 INFO: start
2013-11-13T13:23:54Z 10064 TID-1n41gu UploadWorker JID-03fe3dee40f6390f5cec1d93 INFO: done: 2.779 sec
2013-11-13T13:23:54Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-44f75877c5919302c9ded4fe INFO: start
2013-11-13T13:23:54Z 10064 TID-1w7iwu Sidekiq::Extensions::DelayedMailer JID-44f75877c5919302c9ded4fe INFO: done: 0.038 sec
The issue is, only the mails from sidekiq are shown as sent in log but arent delivered. Other mails from devise n custom mail do get delivered.
Are you sure your development email settings are set correctly? Try setting the following in config/development.rb:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => '127.0.0.1',
:port => '587',
}
Rails 3.2.13, Ruby 1.9.3
My Devise controller is working fine sending emails, with one exception: sending the reset password instructions email.
When I click on the "Forgot your password?" link, I get the message:
You will receive an email with your password reset instructions in a few minutes.
But, I do not receive the email. Following is the relevant dump from the log file:
Started GET "/password/new.user" for 174.xx.xxx.xx at 2013-04-29 01:28:48 +0000
Processing by Devise::PasswordsController#new as
BlogPost Load (0.5ms) SELECT `blog_posts`.* FROM `blog_posts`
Rendered devise/_links.erb (1.0ms)
Rendered devise/passwords/new.html.erb within layouts/application (23.1ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (2.5ms)
Rendered layouts/_promo_bar.html.erb (0.9ms)
Rendered layouts/_footer.html.erb (2.6ms)
Completed 200 OK in 54ms (Views: 51.2ms | ActiveRecord: 0.5ms)
Started POST "/password" for 174.xx.xxx.xx at 2013-04-29 01:30:19 +0000
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"✓", "user"=>{"email"=>"emailaddress#outlook.com"}, "commit"=>"Send me reset password instructions"}
BlogPost Load (137.8ms) SELECT `blog_posts`.* FROM `blog_posts`
User Load (82.4ms) SELECT `users`.* FROM `users` WHERE `users`.`email` = 'emailaddress#outlook.com' LIMIT 1
User Load (14.8ms) SELECT `users`.* FROM `users` WHERE `users`.`reset_password_token` = 'NysDaribCpgNySc5Nmog' LIMIT 1
(0.2ms) BEGIN
(99.0ms) UPDATE `users` SET `reset_password_token` = 'NysDaribCpgNySc5Nmog', `reset_password_sent_at` = '2013-04-29 01:30:19', `updated_at` = '2013-04-29 01:30:19' WHERE `users`.`id` = 113
(60.6ms) COMMIT
Rendered devise/mailer/reset_password_instructions.html.erb (1.3ms)
Rendered devise/mailer/reset_password_instructions.text.erb (1.5ms)
Sent mail to emailaddress#outlook.com (133ms)
Date: Mon, 29 Apr 2013 01:30:21 +0000
To: emailaddress#outlook.com
Message-ID: <517dcd2db584b_71bc6778701193#testsite-test.mail>
Subject: testsite Account Reset password instructions
Mime-Version: 1.0
Content-Type: multipart/alternative;
boundary="--==_mimepart_517dcd2d93927_71bc677870116dc";
charset=UTF-8
Content-Transfer-Encoding: 7bit
----==_mimepart_517dcd2d93927_71bc677870116dc
Date: Mon, 29 Apr 2013 01:30:21 +0000
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <517dcd2d9bfb9_71bc677870117a2#testsite-test.mail>
Hello emailaddress#outlook.com!
A Request to change the password for this account has been received. If this is you, and you still want to change the password, you can do so by clicking on the link below.
Change my password
If you didn't request this, please ignore this email.
----==_mimepart_517dcd2d93927_71bc677870116dc
Date: Mon, 29 Apr 2013 01:30:21 +0000
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <517dcd2db365a_71bc677870118da#testsite-test.mail>
<p>Hello emailaddress#outlook.com!</p>
<p>A Request to change the password for this account has been received. If this is you, and you still want to change the password, you can do so by clicking on the link below.</p>
<p>Change my password</p>
<p>If you didn't request this, please ignore this email.</p>
----==_mimepart_517dcd2d93927_71bc677870116dc--
Redirected to http://test.testsitethefuture.com/login
Completed 302 Found in 2520ms (ActiveRecord: 0.0ms)
Started GET "/login" for 174.xx.xxx.xx at 2013-04-29 01:30:22 +0000
Processing by Devise::SessionsController#new as HTML
BlogPost Load (3.0ms) SELECT `blog_posts`.* FROM `blog_posts`
Rendered devise/_links.erb (0.8ms)
Rendered devise/sessions/new.html.erb within layouts/application (7.0ms)
Rendered layouts/_shim.html.erb (0.0ms)
Rendered layouts/_header.html.erb (2.2ms)
Rendered layouts/_promo_bar.html.erb (1.2ms)
Rendered layouts/_footer.html.erb (2.6ms)
Completed 200 OK in 49ms (Views: 35.9ms | ActiveRecord: 3.0ms)
Any ideas of what I should be looking for?
environments/test.rb
Myapp::Application.configure do
config.cache_classes = false
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.whiny_nils = true
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_dispatch.show_exceptions = false
config.action_controller.allow_forgery_protection = false
config.active_record.mass_assignment_sanitizer = :strict
config.active_support.deprecation = :stderr
config.action_mailer.default_url_options = {:host => 'myapp.com'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "myapp.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: 'Admin#myapp.com',
password: 'xxxxxxxxxxx'
}
end
Check the SMTP Mailer settings in your config file, from log it is showing that mail is sending correctly but it is not delivered, because of SMTP settings problem.
Correct the smtp settings and check the mailer from console
Ex:-
Notification.forgot_password("sample#test.com").deliver
Having the line ActionMailer::Base.delivery_method = :smtp in config/environment.rb overrides ActionMailer::Base.delivery_method = :test in config/environments/test.rb.
So, add that line, ActionMailer::Base.delivery_method = :smtp' from config/environment.rb and place it in config/environments/test.rb. That allows you to place
ActionMailer::Base.delivery_method = :test in config/environments/test.rb.
Note: You must restart your server for these changes to take effect.
In config/environment.rb:
# Configuration for using SendGrid on Heroku
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => 'app[my app number]#heroku.com',
:password => '[something super secret]',
:domain => '[let's get this party started!.com]',
:enable_starttls_auto => true
}
ActionMailer::Base.delivery_method = :smtp
Worked for me.