Detect Disposable Email with Garbage Domain - php

I am developing website using php/codeigniter.
I have downloaded a list of temporary email domains from github (https://gist.github.com/adamloving/4401361)
I integrated this to my website to filter and validate email address.But I noticed that some domains are garbage and cannot detect by the list provided.
Please image below.
Currently Im using this code to filter/validate emails:
public function is_temp_mail($mail='')
{
$this->db->select('domain');
$this->db->from('table_disposal_email_domains');
$domains=$this->db->get()->result();
foreach($domains as $domain)
{
list(,$mail_domain) = explode('#',$mail);
if(strcasecmp($mail_domain, $domain->domain) == 0){
return true;
}
}
return false;
}
How to block garbage domains.Please help.

One of the issue with disposable emails is that new domains are added daily. So, maintaining your own list isn't gonna be enough after a few days.
You can use the validator.pizza API, which is free and updated frequently.
Disclaimer: I made this API 😊

I wrote a simple API for determining the domains of temporary mails, all you need to determine the temporary mail is to send a GET request:
https://api.testmail.top/domain/check/data=example#mail.com&ip=8.8.8.8
with authorization header:
Authorization: Bearer XXXXXXXXXX.XXXXXXXXXX.XXXXXXXXXX
and in response you will receive a message like this if the mail turns out to be temporary:
{
"error": 0,
"result": false,
"message": "This domain is in Blacklist"
}
you will receive such an answer if the mail turns out to be trusted (something like gmail.com or yahoo.com):
{
"error": 0,
"result": true,
"message": "This domain is in Whitelist"
}
I have described error codes and more detailed instructions on this page

It would be good if you use a third party package to help you on blocking temporary email domains. You can use MailboxValidator API, which had 300 free API credits per month. You can use the free API key with MailboxValidator CodeIgniter Email Validation Package after sign up.
Disclaimer: I am working at MailboxValidator.

Related

Whatsapp API - send a notification message to another phone number

I was looking for a way to send notifications directly to the customer phone number using the Whatsapp API
I found an article on a site that explains in detail how to activate and use the Whatsapp API.
Add the phone number +34 644 76 66 43 into your Phone Contacts. (Name it it as you wish)
Send this message "I allow callmebot to send me messages" to the new Contact created (using WhatsApp of course)
Wait until you receive the message "API Activated for your phone number. Your APIKEY is 123123" from the bot.
Note: If you don't receive the ApiKey in 2 minutes, please try again after 24hs.
The WhatsApp message from the bot will contain the apikey needed to send messages using the API.
You can send text messages using the API after receiving the confirmation.
Perfect receipt apikey
How to send WhatsApp Messages from PHP using CURL Library
It is very simple to send WhatsApp messages from PHP using the cURL Library. I would recommend to create a function and then call to the function every time that you want to send a message.
First, create the function "send_whatsapp" in your php code as follow:
function send_whatsapp($message="Test"){
$phone="NUMBER"; // Enter your phone number here
$apikey="YOUR_API_KEY"; // Enter your personal apikey received in step 3 above
$url='https://api.callmebot.com/whatsapp.php?source=php&phone='.$phone.'&text='.urlencode($message).'&apikey='.$apikey;
if($ch = curl_init($url))
{
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
$html = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// echo "Output:".$html; // you can print the output for troubleshooting
curl_close($ch);
return (int) $status;
}
else
{
return false;
}
}
Just update the $phone and $apikey variable with the ones that you obtained during the step 3 above.
And then call to the function from any place in your code.
send_whatsapp("this is a test from PHP"); //Text message that your would like to send
You can call to the send_whatsapp function from different places in your code.
QUESTION
Perfect this will send me a message every time to the number I specified to activate the notification system.
But what if I want to send it not to my number but to the customer number?
I believe you're missing two concepts here. If you want to send messages from your personal phone number, you need to host & run your own solution (I don't think you'd like to allow anybody else out there to get all your stuff).
If you are asking for a service provider to set up a number for you and offer you a gateway service for that purpose, there are several alternatives out there. Google them. You'll find two options; Facebook/Whatsapp API connected providers and 'free riders' that will set that up for you at a cost.
The solution you mention is called call me bot and it is just to send self notifications and not for sending out messages to third parties. I am hosting a similar solution (https://github.com/inUtil-info/whin-use-cases) but is the same situation. To prevent span, you are not allowed to send messages to anyone but you.

YQL request returning Connection refused

The following PHP code (on Laravel) has been working for months until today, where I am now receiving a 502 error indicating connection refused:
$url = "https://query.yahooapis.com/v1/public/yql?q=select+%2A+from+yahoo.finance.quotes+where+symbol+in+%28%27YHOO%27%29&format=json&env=%20store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=";
$data = file_get_contents($url);
dd($data);
When I login to the Yahoo Developer Console to test, I'm able to query the public datatables just fine. However, when I attempt to use the console to access any of the community datatables like this, I am returned the following (this error occurs with all community datatables):
{
"error": {
"lang": "en-US",
"diagnostics": {
"url": {
"execution-start-time": "0",
"execution-stop-time": "7",
"execution-time": "7",
"http-status-code": "502",
"http-status-message": "Connection refused",
"content": "http://www.datatables.org/yahoo/finance/yahoo.finance.quotes.xml"
}
},
"description": "No definition found for Table yahoo.finance.quotes"
}
}
Using a different machine/IP address, I am able to access these community tables just fine as long as I remain anonymous. Once I login to the Yahoo Developer Console, the Connection refused message appears again.
I suspect it has something to do with Yahoo possibly blacklisting my IP address or throttling my account as I run this script for every stock (3,000) once per day.
I attempted to access the URL referenced in the error message content node and it appears this site is down. I'm not sure if this content node matters to the API, as I am able to access it from a different IP address.
I'm open to suggestions and recommendations on how I can determine/fix this problem.
Yahoo Community tables are stored in datatables.org,
and datatables.org is down; that's why there's a querying problem.
http://www.datatables.org
In one of the forum posts, a Yahoo employee has confirmed that the free EOD data has been terminated, and will not be reintroduced. Check out this thread and look for reply from Nixon. Yahoo is recently acquired by Verizon, and it must be the new direction.
However, if you check the Yahoo financial page, the CSV download link works, though differently now. It is through a new API that uses an authentication token "crumb" that is linked to a cookie when you access the page.
I have put together some quick Python3 code to download the same CSV as before through this new API. Please check out the GitHub project yahoo_quote_download.

Trustpilot API not sending invitation e-mails

We have an application which is calling the Trustpilot API to send out invitation e-mails to customers so that they can review their recent orders.
Creating the review link etc. works correctly. However, when calling the final step to actually send out the invitation e-mail, the "status" field of the response is always "notsent" and the e-mail is not sent.
The URL is https://invitations-api.trustpilot.com/v1/private/business-units/business_unit_id/invitations
The JSON response is as follows:
{
id: "<response id>",
businessUnitId: "<business unit id>",
businessUserId: "<business user id>",
recipient: {
name: "<recipient name>",
email: "<recipient email>"
},
referenceId: "<order id>",
templateId: "<default en-GB template code>",
locale: "en-GB",
sender: {
email: "noreply.invitations#trustpilot.com",
name: "<client name>"
},
replyTo: "noreply.invitations#trustpilot.com",
createdTime: "2015-04-29T14:34:40.176727Z",
preferredSendTime: "2015-04-29T14:34:40.176727Z",
sentTime: null,
tags: [ ],
redirectUri: "<trustpilot review url>",
status: "notsent",
source: "Kickstart"
}
We have not modified the SPF record for the client's domain, so I am using noreply.invitations#trustpilot.com as the sender and reply-to addresses. Additionally, I have set the preferred send time so that the e-mail should be sent straight away. Nothing I do is making any difference.
Can anyone advise what I might be doing wrong?
Figured this out - the reply to address I was specifying was being rejected. Even though it was valid (or when I tried using noreply.invitations...) - I switched to using one that the client has been using themselves and they started sending straight away after that.
The reply-to address should be one of the pre-configured addresses in your B2B account. You can see here: https://support.trustpilot.com/hc/en-us/articles/201841237-Sender-Information

Collect data from email message

I want to collect data from email to mysql database using php.
If some one is sent a mail to their mail account to my mail id. I want that mail information to store in my database. for further operation. It is possible in PHP because I saw this feature in one hosting support application Kayako Fusion which developed by PHP.
So plese give some information to do this task.
If you want to parse with PHP the best way is to use a 3rd party API to revive the email and then send it to your PHP script with a HTTP Post.
I'd recommend using either sendgrid.com or mailgun.com
Both of these services will parse the email and send you the information in a http POST that you can then insert into mysql. API docs for both: MailGun Incoming Parse API / SendGrid Incoming Parse API
You can use the imap functions, for example:
<?php
$imap = imap_open("{server.example.com:143}INBOX" , 'login' , 'password');
if( $imap ) {
//Check no.of.msgs
$num = imap_num_msg($imap);
//if there is a message in your inbox
if( $num >0 ) {
//read that mail recently arrived
$the_message = imap_body($imap, $num);
//Do the stuff with $the_message
}
//close the stream
imap_close($imap);
}
You'll have to setup a cronjob (scheduled task on Windows) that connects to the Exchange or POP server, retrieve's all new emails sinds the last run and insert them into the DB.
In case of a POP mail server(I think POP will be easier), there is a comment here with all functions you need right -> here. If that doesn't work, try Googling for "PHP POP wrapper" or something similar.
In case of a Microsoft Exchange server, you'd have to use a PHP Exchange wrapper, found one here for you.
Goodluck!
You can pipe your email to a php script and then extract each part of email and store it in data base.
check this example
when you get content of email you can do what ever you want

XMPPHP as live support chat

My idea is to integrate a live support chat on a website. The users text is send with xmpphp to my jabber client with the jabberbot sender id and if I answer, the jabber bot, takes my answer and transfers the text to the user.
There is only one problem. How do I separate different users or different chats? I don't want all users to see the answer, but the user who asks. Is there a kind of unique chat id or another possibility, that I might just missed?
User => Website => Chatbot => me
I want to answer and send it back to the user, but how can I find out the correct user from my answer?
Last time I have to solve this problem I used this architecture:
Entlarge image
The Webserver provides an JavaScript / jQuery or flash chat.
After chat is started, the client ask the server all 1 Second for new Messages.
Alternative for 1 Sec Polling
If that is to slow for you, have a look at websockets.
http://martinsikora.com/nodejs-and-websocket-simple-chat-tutorial
http://demo.cheyenne-server.org:8080/chat.html
But Websockets could no provided by php. There for you need to change php + apchache agaist node.js or java.
Plain HTTP PHP Methode
In PHP you will connect to the PsyBnc with is polling the messages from the supporter for you.
The PsyBnc is an IRC bot.
The reason why don't directly connect to XMPP or BitlBee is that those protocols don't like the flapping connect, disconnect from PHP. Because you can not keep the session alive, you need something that is made for often and short connects. This is the PsyBnc.
I would use something like this:
http://pear.php.net/package/Net_SmartIRC/download
<?php
session_start();
$message = $_GET['message'];
$client_name = $_GET['client_name'];
if (empty($_SESSION['chat_id'])) {
$_SESSION['chat_id'] = md5(time(). mt_rand(0, 999999));
}
if (empty($_SESSION['supporter'])) {
// how do you select the supporter?
// only choose a free?
// We send first message to all supporter and the first who grapped got the chat (where only 3 gues)
}
$irc_host = "127.0.0.1";
$irc_port = 6667; // Port of PsyBnc
$irc_password = "password_from_psy_bnc";
$irc_user = "username_from_psy_bnc";
include_once('Net/SmartIRC.php');
class message_reader
{
private $messages = array();
public function receive_messages(&$irc, &$data)
{
// result is send to #smartirc-test (we don't want to spam #test)
$this->messages[] = array(
'from' => $data->nick,
'message' => $data->message,
);
}
public function get_messages() {
return $this->messages;
}
}
$bot = &new message_reader();
$irc = &new Net_SmartIRC();
$irc->setDebug(SMARTIRC_DEBUG_ALL);
$irc->setUseSockets(TRUE);
$irc->registerActionhandler(SMARTIRC_TYPE_QUERY|SMARTIRC_TYPE_NOTICE, '^' . $_SESSION['chat_id'], $bot, 'receive_messages');
$irc->connect($irc_host, $irc_port);
$irc->login($_SESSION['chat_id'], $client_name, 0, $irc_user, $irc_password);
$irc->join(array('#bitlbee'));
$irc->listen();
$irc->disconnect();
// Send new Message to supporter
if (!empty($message)) {
$irc->message(SMARTIRC_TYPE_QUERY, $_SESSION['supporter'], $message);
}
echo json_encode(array('messages' => $bot->get_messages()));
Connect the support instant messanger to PHP
We have allready an IRC connection to the PsyBnc, now we need to send messages from IRC to ICQ, XMPP, GOOGLE TALK, MSN, YAHOO, AOI...
Here for is a nice solution named BitlBee.
BitlBee offers an IRC Server with can transfer message from and to nearly all instant messager protocols. By aliasing those accounts. For example you need for your system only 1 Server account at google talk, icq ... and at all your supporter to the buddylist of those accounts. Now BitleBee will provide your boddylist as an irc chat.
Your requirements are rather confusing. As Joshua said, you don't need a Jabber bot for this. All you need is a Jabber server - which you should already have. What you do is, you create a volatile user account sessionid#*yourdomain.com* whenever the chat feature is used and then you can just reply to any incoming message like normal while your website client can fetch the messages meant for it whenever.
Alternatively you could create one user account - qa#yourdomain.com - and use XMPP resource identifiers for the routing part. XMPP allows for something like qa#yourdomain.com/*sessionid* and you should be able to tell your XMPP library to only query a specific resource. Most XMPP client software will also reply to a specific resource by default and open a new conversation when applicable. This method is less "clean" than the first, but it would work somewhat better if you can't arbitrarily create user accounts for some reason.
I don't know what XMPP server you are using, but you could also try the Fastpath plugin and webchat for Openfire. Which is meant to provide a support team service over XMPP.
That being said, your question itself seems to imply nothing more than the standard chat feature of XMPP, which is between two users. It just means that the support person has a unique chat with each user asking a question. No other user will see that conversation.

Categories