I'm writing a mailinglist software in rails and I want to send a recieved email to all the subscribers.
Normally a recieved email from a mailinglist has the sender in the :from key and the address of the mailinglist in the :to key. So it is easy to see who has written the mail and that this mail is for/from the mailinglist.
I generate the mail (in extracts) this way:
mail[:reply_to] = mailinglist.email
mail.delivery_method.settings.merge!(smtp_settings)
mail.deliver
Now I want to deliver it to subscriber.email, but it is delivered back to the mailinglist (because I don't overwrite mail[:to]). But when I overwrite it with mail[:to] = subscriber.email the email contains not the mailinglist as reciever address.
Is it possible to send an email to a other address than in :to?
Edit:
It is also possible to put all subscribers in :bcc and the mailinglist address in :to, but in this case how can I avoid the sending to the :to reciever?
The way this is usually achieved is to put recipients in BCC field of email (hidden copy) so email actually gets delivered but recipients don't see each other's addresses.
Related
I'm using ruby to send transactional emails via Mandrill.
As part of my product, I want to be able to send the same email to two recipients and have them see each other's email address.
(Like an introduction mail between two people).
So I filled he "to" field with both emails, and on my dashboard is seems that both are sent.
But unfortunately only one of the recipients receive the mail and the details of the second recipient is hidden.
In conclusion, I have two problems:
Only one recipient gets the mail
Hidden details of the second recipient.
I approached Mandrill support and this is what they replied:
If you'd like to enable this option globally for all of the messages you send, then you'll want to ensure that you have the
"Expose The List Of Recipients When Sending To Multiple Addresses"
option enabled in your Sending Defaults.
If, instead of making that change globally, you'd like to enable it
for individual messages, you'll want to use the
X-MC-PreserveRecipients (SMTP header), or the preserve_recipients (API
parameter), and set it to 'true'.
If you set this option to true, we'll expose the list of recipients to
each other as you would see happen when sending mail from a typical
email client program.
It worked!
If you want both recipients to be able to see each other, you can pass an array of e-mails in the to option.
If you do not want either of them to see each other, you can, in a loop over the users, send said e-mail.
If using ActionMailer it can be done like so:
mail(
to: ['person1#gmail.com', 'person2#gmail.com']
)
Or in a loop:
[user1, user2].each do |user|
UserMailer.some_email(user).deliver_now
end
mail(
to: user.email
)
Post your code, I have an idea of what your problem may be. Remember that a method in an ActionMailer class should only return mail() and must not be looped over inside of that method.
tldr: do everything unrelated to e-mail outside mailer, pass through necessary data as params to the method, end method with mail() call.
The from portion of the email is saying: From: UnknownSender#UnknownDomain
Could it have to do with this line my in mailer file?
default :from => "DreamStill"
I'm using the SendGrid add on for Heroku. It seems that DreamStill showed up for some addresses, and unknown sender for others.
Specify a valid email address for your "from" field, such as:
:from => "DreamStill <justin#dreamstill.com>"
The way it's being displayed when received by users may very well be dependent on what application is displaying the email, such as Outlook, Gmail, etc.
There's also a number of hurdles, like spam filters, anti-virus scanners, services such as MessageLabs, that email goes through these days. Any one of these could be causing it. Basically, specify a valid email address for the "from" field, and try again.
I have a Rails 3 application that will send mails out to members of a group.
I would like to be able to send out the mails with a single ActionMailer call but specify all the recipients as an array of addresses, e.g.
Emailer.send_newsletters(['user1#domain.tld', 'user2#domain.tld'])
...
def send_newsletters(addresses)
mail :to => addresses, :subject => 'My newsletter to you'
end
Rails will by default make all the recipients visible when sending the mail but I would like that each recipient only sees his own name instead of all.
I will not use a dummy recipient and BCC all real recipients - it needs to be the right recipient.
Is there any way to send the mails without creating a loop around the addresses myself?
No, there isn't. You can send the email to a list of recipients, but they will see all the other recipients. You can assign the recipients to bcc, but the user won't see its address.
The only way to have the user see its own address is to loop all the elements and send one email for each recipient.
If I send the mail to the list of recipients. After that the confirmation mail is send to single person using campaign monitor api.But I want to send the confirmation mail to two or more recipients. could you please answer for this one.
like this:
send = campaign.send!({ :campaignID => campaign.campaignID, :confirmationEmail => #email.from_email, :sendDate => 'Immediately' })
how can i change it for multi recipients.
I don't think Campaign Monitor supports sending multiple campaign confirmations, however you can simply swap out the single email address for an email forwarder on your server which goes to multiple recipients.
I have to send automatic emails with Return Receipt (aka "acknowledgement of receipt"), to have the confirmation that the receiver have actually received and read the email. The confirmation is a simple email sent to a specified address (the "Disposition-Notification-To" address, given in the email header).
Do you know if there is an easy way to do that with Rails (ActionMailer)? or with Ruby perhaps (TMail, Net/SMTP)?
Thanks in advance for your help.
You set your headers in your mailer def block like so:
headers['Return-Receipt-To'] = 'email#example.com'
headers['Disposition-Notification-To'] = 'email#example.com'
headers['X-Confirm-Reading-To'] = 'email#example.com'
Note that these trigger a dialogue in some, but not all email clients. Also, it is not a guarantee that the receiver actually has read and understood the email.