Receiving emails in Ruby - ruby

I'm working with actionmailer. I'm trying to send a mail from email_idA to email_idB, then fetch that email from email_idB, and do some string operations on it to look for specific keywords.
I understood how to send the email. But how do I receive that email from email_idB's inbox? What configurations do I need to do? And how do I extract the email body as plain text?

Did you mean fetch or receive ? Your question uses both these terms and not sure what you mean.
If you just want to do a keyword search on the mails you sent, why not store the outgoing mail in DB and do the search ? (as you said "somehow fetch that email")
To be able to receive emails in your rails app, you would need to implement the receive method in your mailer. Follow this link - link
If you meant fetching emails from your inbox then you have to use POP3. Follow this SO answer - link
Im not sure whats your requirement but I'm sure you will find the above links useful :)

Related

Can i put hidden token inside email while sending email through laravel

I want to send a email to the user from my laravel application. But i want to add a hidden token in that email so that user cannot see it and when user reply to that mail i can read that token and further use it.
Is it even possible?
I am using laravel 5.6 and sending emails using SMTP
There are several ways to do it but none is ideal. Let's start with your idea:
You can add a token within the message, but it can never be invisible, the contents of the message have to be fully visible. Even so, if the reply simply doesn't contain the original message, you will lose the reference
The standard way of tracking replies is based on Message-ID, since every email has to have unique Message-ID. Since you mentioned that you are using SMTP, that allows you to setup Message-ID upfront, otherwise, you'd retrieve it after the message is sent. It helps in a way that you can store that value in the database and automatically link it to the recipient.
Then, you'd look for In-Reply-To: and/or References: headers which should mention the original Message-ID if the reply is properly formatted, which doesn't have to be the case.
Ultimately, depending on your use case, you might not need any of these and you could just keep the sent email based on the recipient email address and extra information that you wanted to pass in the email within your database. Assuming that you'd expect an email from the same recipient email address, you could just figure out the token locally.

Send Mailchimp Campaign to Single Email Address

I'm creating custom emails (many customizations) in MailChimp campaign builder. Looks like the only option to send is via a campaign, which I'd need to manually upload a list of email addresses. I honestly just want to use the builder to send a quality form email, that I customize for each recipient.
Is it possible to send an email to a specific email address without building a list, etc? This will probably be a one-time thing.
You can send campaign to single email address in mailchimp through this method. However you can't send the same campaign more than once to same email address.
create an automation email with API 3.0 as trigger.
Now, to send a campaign, make POST call to the given url with email address in your mailchimp
https://us19.api.mailchimp.com/3.0/automations/********/emails/********/queue
Now, To call that api you need to add HTTP BAsic Auth or OAuth 2 to API Request. See this answer MailChimp 3.0 HTTP POST Json Example
There's also a npm module to make life easier https://npmjs.com/package/mailchimp-api-v3
This is just a workaround as mailchimp was not built for single emails. In the longer run I'd suggest you to look into mandrill, sendgrid or other transactional email tool.
You are better off using Mandrill, MailChimp's transactional email app, to send one off emails. You can still use or at least make use of MailChimp campaigns but you can send one off emails that are customised and you do not need to send to a list

How to know mail send or not send in laravel and which recipient is not getting it?

Hi I am using the bellow function, can you please guide me how can I use Mail::failures(); in it
Mail::send('emails.caregiversetprimary', $templateArray, function($message)use($email)
{
$message->to($email, 'username')->subject('my subject');
});
Mail::failures(); < ====== this gives me black array as I have used wrong email
I am using laravel 4.1
tl;dr
You can know which recipients the email has been sent to but no which recipients have received it.
details
You need a better understanding of how mail servers work. From a Laravel point of view, there is no way (or at least not a simple one*) of knowing which recipients got the email. Its a matter of how mail protocol works. You may know which recipients the message has been sent to but no which recipients actually got it.
With Mail::failures() you get a list of recipients to which Laravel tried to send the email but it failed on actually sending it. But again, if it has been sent there is no straightforward way to known if the mail reached their inbox or no.
*If you happend to use Mailgun, Mandrill or any other 3rd party software then you are not dealing with a mail server 'per se' but with an API service. May be you could check the mail service provider documentation to research if they perform any kind of delivery tracking that you can programatically check.

HTML Emails wIth Images - getting weird results in gmail

I am sending a multipart email through codeigniter using Amazon simple email service SMTP. I am providing a plain text version of the email along with the HTML version and google show the following [image: ][image:][image:} on all the emails. Is there any way to get around this? I have seen this in any email I have received from another company so I figure I am doing something wrong. Any ideas?
To be clear the first few elements in the email are images, however this is no different than I have seen in many emails I receive as newsletters from other companies.
Let me know if you would like more detail, I don't really know were to keep for this one as any search or debugging has made any changes.

Personalized-Mailer-CodeIgniter-Spark

I m using personalized mailer library in Codeigniter for sending emails to customers, mails are going perfectly but how can i get bounced email list. Please help me how to do this...Thanks
Unfortunately servers are not required to send a rejected email request. And those that do, have no standard way of doing so. The gmails and hotmails might, but you cant rely on a response.
If you think about it, it would be a great security concern if that were allowed as you could check for all valid emails at a domain.

Resources