2013-05-31 6 views
5

मैं अपने रेल ऐप में एक्शन मेलर का उपयोग करके ईमेल भेज रहा हूं। लेकिन यह केवल एक डिफ़ॉल्ट प्रेषक की अनुमति देता है।रेल: कार्रवाई मेलर में डिफ़ॉल्ट प्रेषक को बदलें

class UserMailer < ActionMailer::Base 
default :from => "[email protected]" 
def welcome_email(user, order) 
    @user = user 
    @order = order 
    mail(:to => user.email, :subject => "Your Order") 
end 
def signup_email(user) 
    @user = user 
    mail(:to => user.email, :subject => "Thank you.") 
end 
def invite_confirm(curuser,usemail,post) 
    @greeting = "Hi" 
    @user = curuser 
    @post = post 
    mail(:to => user.email, :subject => "Hello") 
end 
end 

मैं इस कोशिश की:

class UserMailer < ActionMailer::Base 
def welcome_email(user, order) 
@user = user 
    @order = order 
    mail(:to => user.email, :subject => "Your Order", :from => "[email protected]") 
end 
def signup_email(user) 
    @user = user 
    mail(:to => user.email, :subject => "Thank you.", :from => "[email protected]") 
end 
def invite_confirm(curuser,usemail,post) 
    @greeting = "Hi" 
    @user = curuser 
    @post = post 
    mail(:to => user.email, :subject => "Hello", :from => "[email protected]") 
end 
end 

लेकिन फिर भी यह "[email protected]"

से ईमेल भेज रहा है किसी भी तरह के लिए इस बदलने के लिए वहाँ है यह मेरा UserMailer वर्ग है UserMailer क्लास में लिखी गई प्रत्येक विधि? क्या मुझे कहीं और बदलना है?

config.action_mailer.smtp_settings = { 
    :address => "smtp.gmail.com", 
    :port => "587", 
    :domain => "gmail.com", 
    :authentication => "plain", 
    :user_name => "[email protected]", 
    :password => "example", 
    :enable_starttls_auto => true 
} 

मुझे लगता है, मैं यहाँ कुछ भी परिवर्तन नहीं होना चाहिए:

config/वातावरण/development.rb और config/वातावरण/production.rb में मैं इस किया है।

उत्तर

5

आप mail विधि के लिए एक पैरामीटर के रूप में यह पारित कर सकते हैं:

def new_mail 
    mail from: "[email protected]", to: "[email protected]" 
end 
+0

अरे, मैं विभिन्न उपयोगकर्ताओं से ईमेल भेजना चाहता हूं। मैंने अपना प्रश्न अपडेट किया। क्या आप इसकी मदद कर सकते हैं? – user2206724

+1

आपको कई ईमेल भेजने की आवश्यकता है :) – e3matheus

2

मुझे लगता है कि आप के लिए-प्रत्येक कार्य के तीन विभिन्न ईमेल के साथ मेल भेजना चाहते हैं। क्योंकि आप जीमेल का उपयोग करते हैं, आपको Sending mail from a different address की आवश्यकता है।

कोई भी विक्रेता सभी तीन प्रकार के ईमेल के लिए इष्टतम नहीं है; आप कई विक्रेताओं का उपयोग करेंगे।

"कंपनी ईमेल" के लिए, यानी ग्राहकों को व्यक्तिगत ईमेल भेजना या व्यावसायिक सहयोगी, आप शायद जीमेल या Google Apps for Business का उपयोग करेंगे। एक ही पते के लिए, आप प्राप्त करने के लिए एक एकल जीमेल खाता और send email from a different address सेट कर सकते हैं। अधिक संभावना है, आप अपनी कंपनी मेल के लिए कई ईमेल पते चाहते हैं। इसके लिए, व्यवसाय के लिए Google Apps का उपयोग करें।

Send Email with Rails

2

मैंने पाया कि, इस SMTP का उपयोग नहीं किया जा सकता। अमेज़ॅन एसईएस का उपयोग करने की आवश्यकता है जो बहु प्रेषक समर्थन की अनुमति देता है।

संबंधित मुद्दे