sending e-mail from Rails Web app without using smtp - ruby-on-rails

I just try to send an e-mail to signed up user from my rails web app. Do I need to use any smtp server or can I just send a mail from my app.? Do you have any suggestion idea about this? Thanks for returns :)

Yes, you need an SMTP server for sending mail.
There are two options, first is to use a mail server provided by someone else, e.g. the SMTP of the company that provides your server or their ISP.
The other option is to install a MTA (Mail Transfer Agent) on your server, one popular options is postfix. See here for instructions for Ubunutu.

Related

Sending email using smtp gmail server from Amazon EC2 instance

I have a gmail for business emailId and would like to use it for sending out messages to my clients. I am using smtp.gmail.com to send out messages from an asp.net mvc application. This works fine on my localhost. But when I deployed the code to Amazon EC2, the functionality broke. I searched and found that EC2 IPs are blackisted by google. How should I fix this? I read that one way is to use Amazon SES, but can anyone tell how does it work? Is it just a verification policy enforcement thing and does it support sending out email from the said gmail account? Is there any other workaround?
Edit 1: As suggested I have contacted Amazon to provide production access. It is in process.
Meanwhile, I am seeing that I am able to send mails from my application. These are my settings -
WebMail.SmtpServer = "smtp.gmail.com";
WebMail.SmtpPort = 587;
WebMail.EnableSsl = true;
WebMail.UserName = "me#example.com";
WebMail.From = "me#example.com";
WebMail.Password = "MyPassword";
WebMail.SmtpUseDefaultCredentials = false;
Is there a reason why suddenly it is working. Is this intermittent or can I move on to using this as such?
SES is the solution for this problem, and then good thing is, unless you are sending 10's of thousands of emails it will only cost you pennies to do - it will allow you to send an email, and make it come from (or appear to come from) your gmail account.
First step is to verify to SES that you own/control the email address you want to send from - that can be done by clicking on a link in an email they send to that address, or else adding some TXT entries to your DNS settings. If you control the domain, I prefer to use the DNS method so that I can verify the entire domain for sending emails, not just the one account - then you can do things like send from 'sales#mydomain.com', 'billing#mydomain.com' etc w/out having to verify each email address individually.
Once you account is verified, sending email from SES using the SMTP option is exactly the same as sending it thru any other SMTP server - use the SMTP server name, username and password from amazon, and away you go.
Very easy, very inexpensive and emails are sent very fast.
Be aware there are limits by default - I believe 5/second and 10,000/month by default - but that can be upped if you have a legitimate need.
Also, once your account is setup with SES, you are not limited to sending your emails just from EC2 instance, you can use it anywhere - for example my outlook email, my mac and my iphone all use SES as my SMTP provider.
I was actually able to send an email using an EC2 instance. Try editing your SMTP Server to ssl://smtp.gmail.com

Sending email to the "outside world" from localhost using hMailServer and Gmail SMTP on Windows 7

I am not sure if this is technically possible but I am running a AMPPS box on Windows 7 as my localhost and I have configured it with Gmail SMTP (ssl://smtp.gmail.com) to send out email from my PHP scripts like joomla, wordpress, socialengine, etc.
Now I installed and setup hMailServer and I am able to send and receive emails locally but was wondering if there was a simple way that I could configure my localhost and email server to send out email to outside world (e.g. #hotmail.com or #yahoo.com receipients) using Gmail SMTP?
Currently with my setup, I am only able to receive installation confirmation emails from AMPPS but nothing else like "Forget Password" or "User Registration Forms" work.
Any ideas without getting too deep into code modification?
The simple answer is no, or rather it is far from easy, especially from a home based server.
And the reason is that your IP address amd mail server domain will not be considered as a ligitimate mail server by most of the legitimate mailservers you will be trying to send mail to, and they will just reject it as yet another spam server.
Have a look at these:
https://serverfault.com/questions/72559/setting-up-a-mail-server-best-practices-to-be-recognized-as-legitimate
How to conduct legitimate email campaigns

How to keep IP trust from email companies when developing in local/test

I am using sendgrid on my Rails app that I am beginning to build.
I am in test mode, mostly doing local stuff but I send many emails to check my process or email layout.
The email I use to receive the emails is on Gmail. I fear Gmail will see there are many emails everyday and never an answer and maybe that the CSS changes a lot, and maybe other factors gmail take into account to assess the trust level of an IP sending emails...
Do I risk Gmail to decrease the trust level of my sendgrid IP? (I don't have much choice during test mode I think)?
What could I do to avoid the IP trust getting hit?
You could use mailtrap to avoid polluting true email addresses. You may check emails sent from their web interface or manually forward them to your inbox.
You could use mailcatcher to catch and view your emails sent from localhost.
MailCatcher runs a super simple SMTP server which catches any message
sent to it to display in a web interface. Run mailcatcher, set your
favourite app to deliver to smtp://127.0.0.1:1025 instead of your
default SMTP server, then check out http://127.0.0.1:1080 to see the
mail that's arrived so far.
In order for you to use it:
gem install mailcatcher
mailcatcher
Go to http://localhost:1080/

How to create individual email id to users on my domain through rails?

I would like to create an email service for all the users on my site, for example: abc#xyz.com, where users will be able to send and receive personalized emails. To start I only need to be able to send and receive emails in Rails.
Users need to be able to register an email at xyz.com and to send and receive emails from xyz.com.
Are there any solutions already available in Rails? Is there any gem or plugin that do this?
If I need to start from scratch, any resource that might helpful for solving the problem would be much appreciated.
Assuming you want to store these users in a SQL database, perhaps you can configure an MTA and an IMAP server to use your Rails database as the user database, then use Squirrelmail or any other web mail client to provide the e-mail user interface.
I believe both Dovecot IMAP server and the Postfix MTA can use MySQL or PostgreSQL to lookup/authenticate users.
There seems to be a webmail app in Rails http://mailr.org/.

I can send an email from my Rails app, but not an SMS text through an email gateway

I have application that needs to send emails and sms text messages. It sends emails just fine, but when I try to send text messages using email gateways (for verizon, xxxyyyzzzz#vtext.com) I get nothing. I have texted the phone using though the email gateway using my gmail account, so I know it works. I would just think that from my app's point of view I am just sending out another email. Any idea why this doesn't work? Or what I can do to troubleshoot it?
I should also note that I am doing this from a Rails app on my local computer...not that it should matter.
Maybe Verizon has software that can identify emails sent from software rather than humans, and rejects yours?
Try making your software add all the same headers (eg. X-Mailer) that a normal email client would add.
Verizon could be doing a reverse DNS query as a simple spam check. Your ISP's info could show up during this look up instead of the return address info that your email message contains, and thus could be getting blocked.
To troubleshot this make sure that the return e-mail address that you are using is coming from an ISP e-mail account.
Here is how to debug it on Linux. Run your Rails application server with strace:
strace -s99999 -e connect,read,write,close -o strace.log script/server
Then examine strace.log and see exactly which SMTP server the Rails application connects to, and what it reads and writes.
Then do the same with your favorite mail client (recommended: mutt, because Thunderbird is slow in strace).
Try to send exactly the same bytes from Rails what your mail client sends.
I have used SMS_Fu in the past to send out text messages. It has worked wonderfully.
I have written a client app for Ruby for sending SMS, please see http://freebiesms.blogspot.com/2009/07/send-free-sms-from-ruby.html to download
complete source code.
Regards
Dan

Resources