w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Send mail via MailGun in CakePHP
(I was having the same errors you were) The BasicTransport didn't have the right "pre-processing" nor the appropriate response handling. I copied over the functionality from CurlTransport and it works for me now. Specifically, we needed: $post = array(); $post_preprocess = array_merge( $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject')), array( 'text' => $email->message(CakeEmail::MESSAGE_TEXT), 'html' => $email->message(CakeEmail::MESSAGE_HTML) ) ); foreach ($post_preprocess as $k => $v) { if (! empty($v)) { $post[strtolower($k)] = $v; } } and then: $response = $http->post($url, $post, $request); i

Categories : Email

Rails devise let user sign in on one rails app by checking the users credentials on a second rails app
I think it can be solved via SSO Maybe it will be useful for you: http://blog.joshsoftware.com/2010/12/16/multiple-applications-with-devise-omniauth-and-single-sign-on/.

Categories : Ruby On Rails

Rails user_path routing to users/index instead of users/id
Have you checked if @user has a value? user_path(@user) will go to /users/<@user.id> but if @user is nil, it will try to go /users/. Given you haven't created the index method and views yet, that will probably be why it fails. Thanks for the test code. Firstly your user is not in the database - change the .new to .create or add a @user.save. Secondly your params[:id] is not populated in the test code so the find will fail (add controller.params[:id] = @user.id to your test). (Thirdly you have a typo shoult instead of should in the last test.)

Categories : Ruby On Rails

sending mail to multiple users through asp.net
public static string sendMail(string[] tolist, string title, string subject, string body) { try { MailMessage mail = new MailMessage(); SmtpClient smtp = new SmtpClient(); if (to == "") to = "----@gmail.com"; MailAddressCollection m = new MailAddressCollection(); //Add this foreach(string to in tolist) { m.Add(to); } // mail.Subject = subject; mail.From = new MailAddress( "----@gmail"); mail.Body = body; mail.IsBodyHtml = true; mail.ReplyTo = new MailAddress("----@gmail"); //And Ad

Categories : C#

What are the easy way to send mail to 1lakhs users using php
It is not suggestable that mailing to all the users at a time but is also not good that mailing one by one but just need to create an for loop for the user upto some limit,like suppose you have 20000users then seperate them into 500 into 40 chunks and make them loop...It is the better option you can do and it doesnt causes any crash your server..BULK mailing is not at all suggestable

Categories : PHP

Get a Wordpress Users E-Mail by Username via Ajax
Get Wordpress user email : http://codex.wordpress.org/Function_Reference/get_userdata So... use Ajax to get that email http://api.jquery.com/jQuery.ajax/ Use include('../../../../../wp-config.php'); (Change your correct path) use this whatever file you want to access your Wordpress db/funcs AND : http://stackoverflow.com/help/asking

Categories : PHP

In rails 4.0, not able to run "rails generate rspec " command
You can get a list of installed generators by typing "rails generate" To generate a spec file for the user model, try: rails generate rspec:model user As noted here https://www.relishapp.com/rspec/rspec-rails/docs/generators and here https://github.com/rspec/rspec-rails

Categories : Ruby On Rails

E-mail app/filter that copies E-mail from the body of the letter and auto replies to that e-mail
I would suggest checking out Google Apps Script. You can create a script just like you would create any other Google Document in Drive by adding the Scripts module from the app store (Scripts is free and created by google). You can also use the gmail API to do the same thing. Both are very well documented and provide a surprisingly high level of access to your emails and their content.

Categories : Email

Why I send a mail with PHP, but receiver get a mail with attachment named "mail.html"?
Did you use any headers? $headers = 'MIME-Version: 1.0' . " "; $headers .= 'Content-type: text/html; charset=iso-8859-1' . " "; // Mail it mail($to, $subject, $message, $headers); Don't use foxmail so no clue if it works...but if you didn't send headers it's worth a try.

Categories : PHP

Submit form from e-mail rails 3
Couldn't make the post request, so just add the get route for the action. Positive part: Worked fine, not complications Negative part: Had to implement some before_filter methods for security due the parameters were passed through the URL

Categories : Ruby On Rails

How to send mail for multiple models in rails
First, in your controller I would store all addresses in one array: @emails = [] if params[:students].present? @emails += Student.pluck(:email) end if params[:teachers].present? @emails += Teacher.pluck(:email) end if params[:parents].present? @emails += Parent.pluck(:email) end UserMailer.send_multiple_email(@emails,@announcement).deliver And then in your mailer change to this: def send_multiple_email(emails,announcement) @announcement = announcement emails.each do | address | mail :to => address, :subject => "Deliver" end end Please note, that if you're referencing your models in the mailer template (such as "Hi <%= @user.name %>!") then you need to load the whole model object. Now you're just using pluck to get a list of all the addresses you want to s

Categories : Ruby On Rails

Specifying "from" email address when sending mail from Rails app
You cannot change the "from" address when sending mail via Gmail. (Unless maybe if you've configured that account to have other "send as" addresses, though I've never tested it) I would suggest trying the free hosted Gmail for your domain, or use a third-party service like Mandrill.com

Categories : Ruby On Rails

Kinda-mass emailing from Rails, but with own mail server
You should decouple your Rails App from the mail sending so that you don't have to wait in your view for the mails to be sent (assuming that you click on something that triggers the start of your mail sending). Use something like delayed_job or another queueing mechanism that Rails offers and only queue up the sending job of the e-mails. Then when the queue comes to execute the particular job you can customize the message with an HTML part and a text part or whatever else you need and pass them on individually to your MTA.

Categories : Ruby On Rails

Let end users edit a pdf in rails?
Check out The Ruby Toolbox page for report generation, specifically PDF_generation. There's a couple of different options with reviews and documentation. https://www.ruby-toolbox.com/categories/pdf_generation

Categories : Ruby On Rails

devise_for :users error in Rails 4
This issue is probably your problem: https://github.com/rails/rails/issues/10559 Suggestions: Remove the attr_accessible in each of your model Add the protected_attributes gem

Categories : Ruby On Rails

Mailgun Email validation API in Node.js
See https://github.com/mikeal/request#requestoptions-callback. The form parameter sets the body of the request, but for a GET request, you want to pass parameters on the query string. Use the qs parameter instead of form for GET requests: var request = require('request') , inspect = require('util').inspect var options = { url: 'https://api.mailgun.net/v2/address/validate' , method: 'GET' , qs: {address: 'john.smith@gmail.com'} , encoding: 'ASCII' , auth: { username: "api" , password: "pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7" } } request(options, function (err, result){ if(err){ console.log(err) } console.log(inspect(result.request.response.body)) })

Categories : Javascript

How can I setup my domain correctly on MailGun?
You need to verify your domain with SPF and DKIM. You can do this by adding TXT DNS records. See more info at https://documentation.mailgun.com/user_manual.html#verifying-your-domain

Categories : Email

Using Mailgun RestFUL's on client-side
According to the Authentication section of Mailgun's API Intro, they require Basic Auth, which is accomplished in code by adding the following HTTP header: Authorization: Basic base64($username:$password) For Mailgun, they mention using api as the username and your API key as the password. For more details on how to add the Basic Auth header via jQuery, see this: How to use Basic Auth and Jquery and Ajax

Categories : Javascript

How do i only allow users that created a category to edit it in rails
Assuming you have 2 join tables: user.rb has_many :categories, :through => :user_categories category.rb has_many :users, :through => :user_categories has_many :bookmarks, :through => :bookmark_categories def is_editable_by?(user) user.category.include? self end bookmark.rb has_many :categories, :through => :bookmark_categories has_many :users, :through => :categories your_view.html.erb if category.is_editable_by? current_user <%= link_to "edit", edit_category_path, category %> end

Categories : Ruby On Rails

upgrade to rails 4, can no longer register users
After some trial and error I found that I had to change the private method in the user model. What works is, Gallery.create(user: self) Thanks for those who responded to help!

Categories : Ruby On Rails

How to manually change what the users see through a back-end of a Rails app?
You will have to use AJAX for sending check calls after a particular duration, you can call the function in a simple JavaScript timer block. The controller can have some status and as soon as it changes, change the ajax response that you are throwing back and on the basis of response java script will change the user view without his prompt just by admins change. hope it helps, ask if something is not clear.

Categories : Ruby On Rails

Search Results Rails SQL - Searching for users
You can use a symbol in your where method to pass in one value for multiple column like this: @usersfiltered = User.where("first_name LIKE :search_name or last_name LIKE :search_name", search_name: "%#{params[:search_word]}%" ) Update: To search for first_name and last_name combined, you could concatenate the two fields and add another OR condition. The problem here is different databases have their own concatenation style. Following are for MySQL and Postgres. MySQL: @usersfiltered = User.where("first_name LIKE :search_name or last_name LIKE :search_name or concat(first_name, ' ', last_name) like :search_name", search_name: "%#{params[:search_word].squish}%" ) Postgres: @usersfiltered = User.where("first_name LIKE :s

Categories : SQL

How to parse data from request posted by Mailgun? C#
If the message pattern repeats with the same order for each message groups, then it may be easy to create a parser that processes the messages and generates the text you want in the format you want. Let me know if you are creating an app in C# for this. If so, I can write you some code to accomplish your task.

Categories : C#

Manging Users through a CRUD Interface -Ruby on Rails
Yes, Rails uses "restful resources" to implement CRUD, it's a very fundamental subject. I would suggest you do some Rails tutorials. "Rails Routing from the Outside In" and "Rails RESTful Resources Tutorial" should get you started. If you want something specifically for users, take a look at the devise gem.

Categories : Ruby On Rails

How do I handle long requests for a Rails App so other users are not delayed too much?
That sounds like a Delayed Job situation. If the first request is just waiting, the most efficient thing to do is assign a process to wait for it to complete and cut the Rails process loose to handle another request.

Categories : Ruby On Rails

ArgumentError in Users#index for Hartl Rails Tutorial
Congratulations on getting to Chap. 9! I'm bored to tears in Chap. 6 Line 2 is this: <%= gravatar_for user, size: 52 %> ...which is equivalent to: <%= gravator_for(user, {size: 52}) %> That's two arguments.

Categories : Ruby On Rails

Need User to login and be directed to localhost:3000/users (rails app)
You can try the following it will redirect to users index page after login. match 'users' => 'users#index', via: :get, as: :user_root Then try this sessions_controller.rb def create user = User.find_by(email: params[:session][:email].downcase) if user && user.authenticate(params[:session][:password]) sign_in user redirect_to user_root_path else flash.now[:error] = 'Invalid email/password combination' render 'new' end end

Categories : Ruby On Rails

Users from sample data populator(faker) it's not visible in my rails app?
I got it ! In database.yml the settings for "test: &test" was set "database: sample_app_development", that was wrong! The correct settings is : "database: sample_app_test" Thanks Szabolcs Mihail for your help :)

Categories : Ruby On Rails

How do I stop users from editing other user posts in Omniauth (rails)
If I read you correctly, your users are authenticated via OmniAuth, but now you're looking for a way to 'Authorize' them for specific resources/actions based on permissions or ownership. The most popular gem for authorization of resources/actions for users, groups, roles, and in-between is CanCan. Can, can you do the CanCan? There is also a railscast video that helped me understand the application of the gem in my applications. Once you know how to write abilities in CanCan, take a look here for an ability that solves your original question on post editing based on the parent user.

Categories : Ruby On Rails

How to find the users within 10miles using latitude and longitude of the user in rails?
class User < ActiveRecord::Base geocoded_by :address after_validation :geocode, if: :address_changed? end User.near([latitude, longitude], 10).to_json # or even simpler since current_user is a geocoded object (i.e has lat/long) User.near(current_user, 10).to_json

Categories : Ruby On Rails

Understanding RSPEC Users tests in Ruby on Rails Tutorial
About your first point, the validation for uniqueness indeed occurs when you call save. However, you can also invoke all the validations by calling valid? - which is what be_valid does. So it doesn't actually need to save the @user model for this test to work. About your second point, RSpec absolutely writes to the database. However, it runs each test within a transaction scope (by default). At the end of each test, instead of committing the transaction, it rolls it back. This leaves the database in the same state it was before the test started, effectively allowing each test to be isolated from the others while making use of the database just as your code would do in production (almost). Regarding your point about the file modification time, SQLite doesn't necessarily write out the

Categories : Ruby On Rails

Rails security attr_accessible users making unauthorized requests
Yeah, you're absolutely right. I think I just realized the answer. Basically when an attribute is not attr_accessible, you want to set it inside your controller directly, which makes it impossible for it to be set with a rogue request like I mentioned above. Also, if your controller is setting a variable directly from params, that's when you know something is wrong and that that variable is basically attr_accessible. Thanks Flo

Categories : Ruby On Rails

Ruby on Rails CanCan, allow users to choose roles on signup
Three possibilities for doing come to mind: Create an administrative interface to enable admin roles to add additional roles via the MVC Add new roles via the console, as you mentioned Seed your database If admins have access to the Rails console (and assuming they know how to use it), option 1 seems like overkill unless you already have other admin functionality rolled into the MVC. Personally, I would opt for the last option. It's as easy as adding through the console, but provides the added benefit of actually committing a history of your changes to code. The nominally simplest way of seeding your DB is using seeds.rb. In it, you can write whatever commands you need to properly seed your database on either an initial or subsequent seed: # db/seeds.rb cities = Role.create([{ name:

Categories : Ruby On Rails

Connect Current_User Account to users Facebook & Twitter Rails
It doesn't matter what attribute name you give it. Just store it in your users table as something and pass it to fb/twitter (as per their API documentation) during your request to these sites. Maybe fb_token and twitter_token? If this doesn't answer your question please elaborate as it is not clear what you're asking.

Categories : Ruby On Rails

How to parse JSON array from message headers with a Mailgun webhook
It's unfortunate the 3rd-party API returns the JSON in [["key","value"],...] arrays rather than {"key:"value", ...}. The latter would be much easier to parse into a typical class like this: public class Foo { public string Received {get; set;} [DataMember(Name = "Content-Type")] public string ContentType {get; set;} ... } The way it returns is an anonymous list of values, containing more anonymous lists, where the 0 value is the key and the 1 value is the value. I haven't tried it, but you may want to try deserializing to dynamic list of anonymous types, per this SO answer List<JsonObject> jsonObject = JsonArrayObjects.Parse(json); jsonObject.PrintDump(); // show data Then for convenience, you could write a mapping routine to copy the jsonObject to a more rea

Categories : C#

A rails app which gets users location using HTML5 geolocation and saves to data base
Check out this answer. Basically, just set the geolocation via a cookie and read the lat and long from the cookie in your controller.

Categories : Ruby On Rails

Rails Devise+Omniauth Facebook redirect to users/sign_up fails
You have ot specify two URL while calling Auth. 1) Success which will redirect sucesses params after successfule login 2) Error if anything bad happens. These you have to specify while you create the FB application with your domain name. callback_url / callback_path is the name of the variable is above that you can pass via the call. Ref https://github.com/mkdynamic/omniauth-facebook Hope this helps.

Categories : Facebook

Rails Asociations - Multiple users fullfilling different roles for single model
Ok i would do something like this: on my create Match action i would create the match like this Match controller: def create @match= Match.new(params[:match]) @match.creator_id = current_user.id respond_to do |format| if @match.save format.html else format.html end end end asuming you are using something like devise and that the match model has both of the users and one is the creator_id

Categories : Ruby On Rails

How to Route Multiple Pages to 'Edit' a Users Account Information (Rails)
Split the form up into separate .html.erb files (like email.html.erb and password.html.erb) and in your controller write something like: def edit ... if params[:email] render 'email' end if params[:password] render 'password' end end Obviously the conditions can be whatever you want.

Categories : Ruby On Rails

Rails: How to enable users to create a record but requires admin approval before posting
You can allow all users to create projects, but allow only admins to approve them. And on projects index page you can list only approved projects. class Ability include CanCan::Ability def initialize(user) can :create, Project if user && user.admin? can :approve, Project end end end Projects controller: def index @projects = Project.where(approved: true) end def approve if can? :approve, Project @project.update_attributes approved: true end end I assume that new projects are created with approved: false.

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.