Get the list of mail chimp subscribers in rails - ruby-on-rails-4

I am working on a simple rails rails app and i have so many subscribers in my mail mailchimp account and i want to get my all subscribers and send the a mail from my rails app. How do i get my subscribers emails in an array.
my code sample is below
def send_now
#news_letter = NewsLetter.find(params[:id])
gb = Gibbon::API.new("xxx")
members = gb.lists.members({:id => 'xxx'})
#for each goes here to send the mail
redirect_to manage_news_letter_path(#news_letter), notice: "Sent news Letter"
end
I can get the list of subscribers but how can i split out their email into a for_each method in rails cos the format is i in a hash. any help thanks.
example output is below
{"email"=>"xx#xx.com", "id"=>"xx", "euid"=>"xx", "email_type"=>"html", "ip_signup"=>nil, "timestamp_signup"=>nil, "ip_opt"=>"208.68.37.172", "timestamp_opt"=>"2014-02-21 10:38:20", "member_rating"=>2, "info_changed"=>"2014-02-21 10:38:20", "web_id"=>xx, "leid"=>xx, "language"=>nil, "list_id"=>"xx", "list_name"=>"Blanckdigital website List", "merges"=>{"EMAIL"=>"xx#xx.com", "FNAME"=>"", "LNAME"=>""}, "status"=>"subscribed", "timestamp"=>"2014-02-21 10:38:20", "is_gmonkey"=>false, "lists"=>[], "geo"=>[], "clients"=>[], "static_segments"=>[], "notes"=>[]}
what i want is is just the email xx#xx.com alone for each of the subscribers

Related

How to get "starred mails" from Gmail or other mail services using IMAP_tools in django

I am able to get inbox emails and also able to get emails from specific folder but i am unable to get "starred" emails.
I tried below code. and i am expecting emails with "starred flag" in response.
from imap_tools import MailBox, A
# Create your views here.
def temp(request):
#Get date, subject and body len of all emails from INBOX folder
with MailBox('smtp.gmail.com').login('admin#gmail.com', 'password', 'INBOX') as mailbox:
temp="empty"
for msg in mailbox.fetch():
temp = (msg.date, msg.subject, msg.html)
return HttpResponse(temp)
https://github.com/ikvk/imap_tools/blob/master/examples/search.py
mailbox.fetch(AND(flagged=True))
(A long time ago in a galaxy far far away) star looked like a flag.

How can I add an unsubscribe link in a single email with Mailgun using SMTP?

I am having trouble figuring out how to put an unsubscribe link in my email that is SMTP integrated with Mailgun.
Any thoughts?
Mailgun provides you with several unsubscribe variables:
1) %unsubscribe_url% -- link to unsubscribe recipient from all messages sent by given domain
2) %tag_unsubscribe_url% -- link to unsubscribe from all tags provided in the message
3) %mailing_list_unsubscribe_url% -- link to unsubscribe from future messages sent to a mailing list
If you include these variables in your emails, any recipient that clicks on the url will be automatically unsubscribed and those email addresses will be blocked from receiving future emails from that domain or message tag as appropriate.
reference https://documentation.mailgun.com/user_manual.html#tracking-unsubscribes
You can use it in a href link:
Click here to unsubscribe
Instead of giving entire domain as %unsubscribe_url% , it is better to add %tag_unsubscribe_url% only, so that all the tags which are part for the current email will get unscubscribe.
Here is the code
HTML link will be like
<a style="color: #8798AD;margin: 0;text-decoration: none;" href="%tag_unsubscribe_url%">Unsubscribe</a>
This will add unsubscribe link to all tags which are part of the current send email request.
so, it my send email request has 2 tags (i.e. Orage and Mango) this two tag will get unsubscribe by mailgun.
So if you send any email which contains one of these tag, then that email will not get deliver to client.
Java code example:
String from = "alpesh#jikadra.com";
String to = "alpesh#stack.com";
String subject="Sample email";
String replyTo="no-reply#jikadra.com";
String html = "<body><h1>Hello</h1><a style="color: #8798AD;margin: 0;text-decoration: none;" href="%tag_unsubscribe_url%">Unsubscribe</a></body>";
List<String> tags = new ArrayList<String>();
tags.add("Mango");
tags.add("Orange");
MailGunRequest mailGunRequest = new MailGunRequest(from, to, subject, html, tags, replyTo);
ResponseEntity<MailGunResponse> mailGunResponseResponseEntity = mailGunClient.sendEmail(mailGunRequest);
for more reference refere : https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api

Is it possible to extract emails from an email list

So my university has an email list in the form of:
students#lists.university.edu
If I send an email to students#lists.university.edu it will send the email to all people in the list. My question is, how do I extract the emails individually giving me:
email1#university.edu
email2#university.edu
email3#university.edu
email4#university.edu
email5#university.edu
email6#university.edu
email7#university.edu

Redirect users to their specified email accounts with receiver and message fields pre-filled

I have an email address "myaddress#gmail.com". I have created a django form that has a text field and a button. I want to redirect anyone who types a message in the text box to their respective emails so that they can send the message they typed to "my address". This means that as they log in to their email accounts, their message boxes should already be filled with the message they typed and the receiver field should already have "myaddress#gmail.com". The problem is how to redirect the users to their email accounts and prefill the specified fields.
Can anyone help me please?
If the user has set a default email program, most of them will be triggered on mailto:. I know gmail works with mailto: as well, and its possible that other web email services might. All desktop email clients - again only if it is set as the default email program will work on mailto:
The format is:
mailto:[emailaddress]?header=value&header1=value1....&headerN=valueN
Here is an example that sets the subject of the email automatically:
Email me

How to get the sending user's id from the callback page with fb-request-form?

im sending invitation requests via the request-form to my application and i want to the sending users id from the action page. i can successfully get the ids the invitations are sent to but am not sure how to get the senders id.
im using php. this is part of my callback page:
if (isset($_REQUEST['ids'])){
$amount = sizeof($_REQUEST['ids']);
print_r($_REQUEST);
echo "<br>$amount invitations Successfully Sent";
}
the request prints out like this:
Array ( [mfs_typeahead_req_form_4cf74f96db3688507476560] => Start Typing a Name [ids] => Array ( [0] => 510149460 ) [fbs_258181898823] => \"access_token=258181898823|2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700|LqtGr_OiJTASGmek61awxmxfvFk&expires=1291280400&secret=85eTEELZj8lkV82V_PwRSA__&session_key=2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700&sig=d4cc0e4c0992ea29c0adfd60dc27185b&uid=100000664203700\" )
the id i want is 100000664203700
If using requets 2.0 http://developers.facebook.com/docs/reference/dialogs/requests/
You can get the user id form current session and append to the data parameter in the request. Facebook will send the data though as a string and you can extract on the redirect uri.
as per your print_r() Have you tried json decoding the $_REQUEST? This will give you an array to work with and you can do a quick search for uid= in your string.
http://php.net/manual/en/function.json-decode.php