FYI, this return "Ok" for both existing and non-existing emails
if(Mail::failures()) { foreach(Mail::failures() as $failure) { echo $failure . ''; } } else { return "Ok"; }
Hi all;
I want to make a simple app that checks to see if given email is real or not. So far i have set up smtp driver with gmal host and it works fine. I can send mails to valid and real email addresses as well as unreal email addresses.
But if the given email was not real, my host gmail address receives an email that says the given email address was not real.
How can i see this in my laravel app rather than receiving an email says it was not real?
My implementation is below:
//---------------------------------------------- public function send() { $email = new Email(); Mail::to(request('email'))->send($email); return redirect()->back(); } //-----------------------------------------------
My .env is below:
//----------------------------------------------- MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 MAIL_USERNAME=my_gmail.gmail.com MAIL_PASSWORD=my_gmail_password MAIL_ENCRYPTION=tls
FYI, this return "Ok" for both existing and non-existing emails
if(Mail::failures()) { foreach(Mail::failures() as $failure) { echo $failure . ''; } } else { return "Ok"; }
Mail() can only tell that it sent something "out" successfully. There is no way for it to know whether it arrived at the destination, or bounced, or anything else once it "leaves" php. It just knows there wasn't a malformed email sent out.
The complicated way would be to use php's imap functions, and have your code actually login to your email server periodically and manually parse incoming emails to see if there was a bounce. http://php.net/manual/en/book.imap.php I'm sure there are packages that can do this, I haven't looked.
I'm not sure how you are collecting the email addresses that you are sending to. Are they user emails or subscribers to your system? If that's the case, it's best to send them a confirmation email when they sign up and don't activate their account until they click a link in your verification email or something. If you are getting them from some outside source, like a list, then you kind of need to do what I mentioned above if you really need to know if an email account is legit. It can be a long process to get the actual result. Some ISP's don't bounce an email for hours, or even days.
The app is gonna be a small part of a bigger system.It is not a full auth solution itself. It will just check (about 10.000 email addresses) to see if an email address is real or not.
What do you suggest i should do?
(i thought i should send each one an email and see if it got delivered. if there is a better way, which it should be, please inform me) TIA
Some ISP's don't bounce an email for hours, or even days
Additionally, many don't generate bounces at all due to backscatter. I used to run a fairly busy mailserver and eventually disabled bounces for anything outside my domain. Though I started in ye olden days and you could still send vrfy commands over smtp - but those days are long gone due to spammers running vrfy commands for every combination of names to find valid addresses :-/
Other than a confirmation as @Cronix suggests, there's not much you can do automatically. At most (I think) you could do a quick dns lookup of the domain name and see if it existed (ie, if the email is "[email protected]" do a dns check on "whatever.com"). But seeing as so many domains are bought and 'parked' now I'm not sure how much that would help.
I guess you could do a rough algorithm like 'if there are more than X addresses at a given domain then assume it's valid' - but not sure if that would help much.
you could send your emails via http://postmarkapp.com
You can turn on delivery tracking and then use an API webhook to receive a call when a message was delivered. you can then change the status on the email address.
I have found a site ( http://email-checker.net/ ) that does what i need and they say they achieve this way:
"Email Checker is a simple tool for verifying an email address. It extracts the MX records from the email address and connect to mail server (over SMTP and also simulates sending a message) to make sure the mailbox really exist for that user/address."
If it's not much to ask, how can i achieve this with laravel ?
@haruntunay I haven't tried it, but found this which seems to do what you described: https://github.com/webdigi/SMTP-Based-Email-Validation
It's just a single php class (not laravel specific), so you should be able to use it in pretty much any project.
Thank you for suggesting but i have already tried this. I get this error below;
fsockopen(): unable to connect to alt3.gmail-smtp-in.l.google.com:25 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
I guess my connection request got refused. I have tried many ports with many different email addresses, still no result.
I will keep you guys updated if i can solve it. TIA
Hi! i have found https://email-check.org is free site that detect if email exits, gmail,hotmail,yahoo... and also get information from facebook and twitter, name, city, likes...
Email-checker is a nice tool but it can not detect catch-all email s or spam traps. I would suggest other provider quickemailverification mentioned in below article - https://www.accuwebhosting.com/blog/top-10-bulk-email-list-verification-validation-services-compared/
@haruntunay Do what millions of other websites do and send a verification email to the address. Only let the user use your application if they click a link in the email, thus proving that email "exists".
@haruntunay instead of manually creating an app for email verification, you can verify your emails from the list cleaning service providers. This will help you in saving time and efforts that you can invest in other important tasks. However, if you are facing some trouble in finding email list verification tools you can go through this page https://www.formget.com/email-list-cleaning-service/.
Checking an email for its validity is very much important, not only it saves on email marketing cost but also prevents from hitting the dreaded spam folders. An email can be easily validated by using an email validation tool here is the list of trusted email validation services in the market to help you check any email address - http://letswordpress.com/email-validation-and-email-verification-tools-compared/
There are many email verification tools (eg. https://www.emaillistverify.com/) which are able to check if email address really exists without sending an email message.
If the tools to verify an email exist, it is because it can really be done. So far the only thing I do in greet the mail server with the validation of laravel
return [
"email" => ["email:dns"]
]
And in addition to this what I do is have a blacklist with the emails to which the delivery was rejected.
This last part is given directly to aws with the status of mail delivery.
Please or to participate in this conversation.