Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

Showing posts with label mail. Show all posts
Showing posts with label mail. Show all posts

Using your GMail as ActionMailer Carrier

this was merely a try, it worked, but i don't think it's recommended so much, google might get angry.

create a conf file named ssmtp.conf in /etc/ssmtp

  1. # Config file for sSMTP sendmail  
  2. #  
  3. # The person who gets all mail for userids < 1000  
  4. # Make this empty to disable rewriting.  
  5. root=postmaster  
  6.    
  7. # The place where the mail goes. The actual machine name is required no   
  8. # MX records are consulted. Commonly mailhosts are named mail.domain.com  
  9.    
  10. # GMAIL configuration  
  11. mailhub=smtp.gmail.com:587  
  12. AuthUser=youremail@gmail.com  
  13. AuthPass=pass  
  14. UseSTARTTLS=YES  
  15.    
  16. # The full hostname  
  17. hostname=machinehostname  
  18.    
  19. # Are users allowed to set their own From: address?  
  20. # YES - Allow the user to specify their own From: address  
  21. # NO - Use the system generated From: address  
  22. FromLineOverride=YES  


then just point ActionMailer to user sendmail as carrier in your environment:

  1. ActionMailer::Base.delivery_method = :sendmail  


and you are all set

Mean Mail Machine

i was trying the other day to create some sort of a newsletter. sadly it took me about 2 hours to generate and send 51000 emails (not spam :) ) so i tried to find a way to do it a little faster.
a friend of mine came across the idea of using threads so i tried to override the basics of ActionMailer in order to make the delivery method to user threads.
the change boosted me up to 18-20 mails per second, in other words, 1900% more efficient!
here is the code, just push it in your environment.rb (or lib, whatever), just don't use it for mean/nasty/microsoft needs :).

  1. ActionMailer::Base.delivery_method = :thread_smtp  
  2.   module ActionMailer  
  3.     class Base  
  4.       def perform_delivery_thread_smtp(mail)  
  5.         thread = Thread.new do  
  6.           perform_delivery_smtp(mail)  
  7.         end  
  8.         thread.run   
  9.       end  
  10.   end  
  11. end  


The Web Ask eizesus.com

Subscribe

    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.

    Labels