我正在从 gmail 导入联系人列表,并使用复选框选择返回的电子邮件,并在用户被选中后向用户发送邀请。当我查看我的日志时,输出的电子邮件格式正确,一切似乎都很好。
当我在 Sendgrid 上查看我的电子邮件活动时,我看到电子邮件地址附加了额外的字符,因此使其失败。我使用 sendmail 与其他邮寄者发送电子邮件没有任何问题,但这个似乎添加了这些额外的字符,我不知道它们来自哪里。
有没有其他人看到这种情况发生?或者对如何解决这个问题有建议?
预期结果邮箱:test@gmail.com
实际结果邮箱:“test@gmail.com”@i04-01
user_mailer
def invitation(email_addresses)
@host = ((Rails.env == "production") ? "http://www.test.com" : "http://localhost:3000")
attachments.inline['people.jpg'] = File.read("#{Rails.root}/app/assets/images/people.jpg")
#attachments.inline['people.jpg'] = File.read("#{Rails.root}/app/assets/images/Girl.jpeg")
email_addresses.each do |email|
mail(:to => email, :subject => "Hello from test!")
end
结尾
用户控制器
def import
#@user = User.find(params[:id])
#@users = User.find(session[:user_id])
begin
@sites = {"gmail" => Contacts::Gmail, "yahoo" => Contacts::Yahoo, "hotmail" => Contacts::Hotmail}
@contacts = @sites[params[:from]].new(params[:login], params[:password]).contacts
@users, @no_users = [], []
@contacts.each do |contact|
#if u = User.find(:first , :conditions => @users.email = �#{contact[1]}� , :include =>[:user])
if u = User.find(:first, :conditions => "email = '#{contact[1]}'")
@users << u
else
@no_users << {:name => contact[0], :email => contact[1]}
end
end
#if @contacts.save
#end
respond_to do |format|
format.html { render :template => 'shared/_contact_list', :layout => false }
format.xml { render :xml => @contacts.to_xml }
end
end
结尾
def send_bulk_mail
name_email =[]
email_addresses=[]
names=[]
post=params[:post]
post.each do |k,v|
if v=="1"
name_email << k
end
end
name_email.each do |n|
email_addresses << n.split(",")[1]
end
UserMailer.invitation(email_addresses).deliver
结束 谢谢