smtp email varification

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

smtp email varification

Post by gautamz07 »

Hey guys , i am using this library here https://github.com/zytzagoo/smtp-validate-email to validate , is the email address provided really exists.

so i basically have created a index.php page with the following code:

<?php

Code: Select all

require('smtp-validate-email.php');

$from = 'a-happy-camper@campspot.net'; // for SMTP FROM:<> command
$email = 'someone@somewhere.net';

$validator = new SMTP_Validate_Email($email, $from);
$smtp_results = $validator->validate();

var_dump($smtp_results);
my question is, how do i echo to the screen to see if the email address is valid or not . if i do ,

Code: Select all

echo $smtp_results;
i get

Code: Select all

Array
on the screen.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: smtp email varification

Post by social_experiment »

Code: Select all

<?php
var_dump($smtp_results);
?>
what is returned from this
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: smtp email varification

Post by gautamz07 »

I don't get anything on the screen ! :(
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: smtp email varification

Post by social_experiment »

Code: Select all

<?php
try {
	$validator = new SMTP_Validate_Email($email, $from);
	$smtp_results = $validator->validate();
	
	var_dump($smtp_results);
	}
	catch (Exception $e) {
		echo $e->getMessage();
	}
?>
returns this:

[text]
array(2) { ["someone@somewhere.net"]=> bool(false) ["domains"]=> array(1) { ["somewhere.net"]=> array(2) { ["users"]=> array(1) { [0]=> string(7) "someone" } ["mxs"]=> array(1) { ["somewhere.net"]=> int(0) } } } }
[/text]
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: smtp email varification

Post by gautamz07 »

Thanks dude ! that was really helpful !
Post Reply