PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, November 14, 2022

[FIXED] how to mask recipients addresses , action mailer 4 with bcc: or other

 November 14, 2022     actionmailer, mailing, ruby-on-rails     No comments   

Issue

I am using action mailer with an array of emails. Emails are sending out successfully but in the received email, everyone can see the other recipients. I want to hide them from each other.

There are many posts about this and I've tried many things without success. Would be great if someone can spot what I'm doing wrong. I'm using rails 4.1.7. with delayed_job and devise. I am sure this must be something easy i have missed. Thanks in advance for any help.

My mailer is :

def send_email(mymodel)
  @mymodel = mymodel
  emails = @mymodel.followers.collect(&:email) 
  @url  = 'http://example.com/'
  mail(:to => emails, :bcc => ["noreply@example.com"], subject:"myemailsubject")  
end

Solution

mail(to: emails, bcc: ["noreply@example.com"], subject: "myemailsubject")

You could exchange the bcc value with the to value.

mail(to: ["noreply@example.com"], bcc: emails, subject: "myemailsubject")

That should send out only 1 email, yet achieve what you want. However the email recipients might be slightly confused if they read the to field and don't find their own email address.

You could try the following but obviously it'll send out multiple emails:

emails.each do |email|
  mail(to: email, bcc: ["noreply@example.com"], subject: "myemailsubject")
end


Answered By - SHS
Answer Checked By - Marilyn (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing