amuck-landowner

can anyone help me integrate emailing into my script?

devonblzx

New Member
Verified Provider
You have a very strange check in place.

You are converting an array to a JSON string just to check a strpos.  Why not check if a key exists in the array?

Edit:  It looks like an empty array will be returned if the DNS server returns NXDOMAIN.  So better yet, you could do:



if (count(dns_get_record($ipordomain . ".zen.spamhaus.org")))
But you would need to reverse the ip for the DNS lookup.
 
Last edited by a moderator:

HBAndrei

Active Member
Verified Provider
Here's a simple alternative:
 


<?php

$IP = $_REQUEST['IP'];
$reverse_ip = implode(".",array_reverse(explode(".",$IP)));

$RBL = "zen.spamhaus.org"; // Set your RBL here

if(checkdnsrr($reverse_ip.".".$RBL.".","A")) { // IP is listed
// Do stuff here
// Here you can also handle the return codes if you wish to know exactly what the IP is listed for
// As explained here: http://www.spamhaus.org/news/article/713/changes-in-spamhaus-dbl-dnsbl-return-codes
$return_code = gethostbyname($reverse_ip.".".$RBL.".");
}
else { // IP is not listed
// Do other stuff here
}

?>

I hope this helps you out.
 

Kayaba Akihiko

New Member
Here's a simple alternative:


<?php

$IP = $_REQUEST['IP'];
$reverse_ip = implode(".",array_reverse(explode(".",$IP)));

$RBL = "zen.spamhaus.org"; // Set your RBL here

if(checkdnsrr($reverse_ip.".".$RBL.".","A")) { // IP is listed
// Do stuff here
// Here you can also handle the return codes if you wish to know exactly what the IP is listed for
// As explained here: http://www.spamhaus.org/news/article/713/changes-in-spamhaus-dbl-dnsbl-return-codes
$return_code = gethostbyname($reverse_ip.".".$RBL.".");
}
else { // IP is not listed
// Do other stuff here
}

?>

I hope this helps you out.
Thanks!

The mail function is the easiest method. If you want better options though SMTP isn't hard to add with some easy options out there to implement.


mail() = http://php.net/manual/en/function.mail.php
I tried the mail function, it didn't work sadly

You have a very strange check in place.

You are converting an array to a JSON string just to check a strpos.  Why not check if a key exists in the array?

Edit:  It looks like an empty array will be returned if the DNS server returns NXDOMAIN.  So better yet, you could do:



if (count(dns_get_record($ipordomain . ".zen.spamhaus.org")))
But you would need to reverse the ip for the DNS lookup.
Thanks for the code, I'm lousy at PHP so my coding practices are usually crap
 
Top
amuck-landowner