i've been using ruby pony gem to send emails
https://github.com/benprew/pony#readme
unfortunately documentation is not as big as i wish, just shows few methods to send email, but seems that doesnt return any message when the mail cannot be sent.
does anyone have this trouble ? so i wish to know if pony was not able to send email to tell the user that couldnt happen.
should i try with exceptions ? i'm new in ruby so i have tiny knowledge to make a decition.
Kind regards.
Pony can throw exceptions from the Net::SMTP or Mail gems on failure, so you can catch that exception and show the user the error message. See posts like this on the Google Group, though details are a bit scarce.
Related
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.
I am working on a Sinatra web app that needs to save any email that it receives in a db (or do something else as soon as a mail is received). What is the best tool for this job? I was looking at eventmachine and it seems a bit complex. I was considering the mail gem but it doesn't trigger events when mail is recieved. One final query: To test such an app, do I need it to host it online? If not, then how to do I send emails to the app and test?
Thanks a lot,
So Sinatra is a web server. Email doesn't come in from HTTP requests, so you need a mail server to receive the emails and assuming you still want to handle them in your Sinatra app, fire a request at your app.
check out http://steve.dynedge.co.uk/2010/09/07/incoming-email-in-rails-3-choosing-the-right-approach/ for a few options (it's thinking rails, but you should be able to translate)
Is there some way to receive emails with Sinatra? I've seen the pages that say how to do it with RoR, but none without. I have also found out how to send emails with the gem Pony. Thanks!
I believe you are looking for the mail gem (github). It has send and receive capability.
Update: I forgot that there is a Google Group too
Rails uses mail gem in order to send and receive emails. This gem can be used in Sinatra just as easily.
When using Perl's Net::Jabber, sending a simple message to an offline user causes the message to be delivered to the user when he comes online (it even show's in the user's gmail account as unread messages). That's as simple as doing
my $msg = Net::Jabber::Message->new();
$msg->SetMessage(...);
$connection->Send($msg);
In Ruby xmpp4r, doing the same equivalent thing does not send the message to an offline user, instead returning (async) a xmpp service-unavailable stanza or even not returning anything, and also not working. Message is simply lost.
How can one send an offline message with xmpp4r?
Also, in related subject, in xmpp's api docs for Jabber::Stream's send method, there is a "block" parameter. How does one use that?
Thanks
Make sure that you're doing type=:chat on the message.
client.send(Jabber::Message.new(jid, contents).set_type(:chat))
(code copied from Ricardo Pardini's comment, for long-term clarity)
I am trying to write a program in Ruby that can send a email to a phone. Outside of the program, I am able to do this by sending an email to xxx-xxx-xxxx#vtext.com or any other carrier in my Apple Mail client, and it worked fine; it sends a text message to the targeted phone, but when I tried to use a Ruby API (I forget the name), that used sendmail, to send a message, it would not send the message. Are there any ruby APIs that can send an email to a phone? (Or can someone just list some different Ruby mail APIs that I can try)?
I've used ActionMailer and Pony (http://github.com/benprew/pony) in the past.
it should "just work" assuming your mailing system/settings are setup right.