Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Developers' Forum

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 18th April 2012, 14:54
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default domain_error_unique when there is no domain in db table

Hi guys,

I have tested this simple code:

Code:
$params = array(
			'server_id' => $ServerId,
			'domain' => $domain['domain'],
			'active' => 'y');
try{
	// Get the domain name ID
	$record = $client->mail_domain_get_by_domain($this->getSession(), $domain['domain']);

	// Create the mail domain
	if(empty($record['domain_id'])){
		$domainId = $client->mail_domain_add($this->getSession(), $clientId, $params);
	}else{
		$domainId = $record['domain_id'];
	}

     echo $domainId;	

} catch ( SoapFault $e ) {
	throw new Exception("There was a problem with the Mail Domain creation: " . $e->getMessage() . " - " . __METHOD__ . " - Paramenters: " . json_encode($params) , "3506");
}
If you execute this code you'll get the exception domain_error_unique

why this happens?
Reply With Quote
Sponsored Links
  #2  
Old 18th April 2012, 15:01
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

Either there is already a email domain with that value or the domain variable is empty or a similar problem.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 18th April 2012, 15:03
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default

these issues suggested are already tested.
Reply With Quote
  #4  
Old 18th April 2012, 15:06
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

Take a look at the mail_domain table in the ispconfig database with phpmyadmin to ensure that it is really empty.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.

Last edited by till; 18th April 2012 at 15:17.
Reply With Quote
  #5  
Old 18th April 2012, 15:07
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default

It's not important if there is already a domain saved in the db because I check if the domain exist before.
Reply With Quote
  #6  
Old 18th April 2012, 15:16
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

It is important if there is a domain in the DB as you cant add a duplicate domain and the error that you get tells you that there is already that domain in the mail_domain table. So check with phpmyadmin if the mail_domain table is empty or not.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #7  
Old 18th April 2012, 16:05
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default

As you can see in the code posted I check if the domain exists in the db using the mail_domain_get_by_domain method.

If the domain exists the creation of the new mail domain is not a problem because the condition check if it exists or not.

So if the problem is not of the mail_domain_add method maybe the problem is mail_domain_get_by_domain that doesn't get the domain from the db.
Reply With Quote
  #8  
Old 18th April 2012, 16:27
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
Default

Try:

$record = $client->mail_domain_get($this->getSession(), array('domain' => $domain['domain']));

if(coun($record) > 0) {
echo 'domain exists';
} else {
echo 'domain does not exist';
}
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 18th April 2012, 17:56
vaio1 vaio1 is offline
Senior Member
 
Join Date: Jul 2007
Location: Italy
Posts: 664
Thanks: 77
Thanked 12 Times in 7 Posts
Default

Hi,

done but the problem persists. count(record) = 0 even if there is a mail domain.

regards
Reply With Quote
  #10  
Old 18th April 2012, 18:00
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 35,466
Thanks: 813
Thanked 5,253 Times in 4,119 Posts
 
Default

Then it might be that the variable $domain['domain'] does not contain the domain, as the query functions for mail domains work properly on my servers.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail -Ubuntu 8.04 c4rdinal HOWTO-Related Questions 112 23rd August 2011 10:49
Postfix queue problem? murunix Server Operation 7 2nd May 2011 01:55
mail.err warnings and some mail unable to receive HellMind General 4 8th October 2010 19:57
ISPConfig3 Mail Warn Errors reason8 General 3 25th November 2009 13:58
CentoS doesn't send the emails vaio1 Installation/Configuration 18 5th November 2008 17:51


All times are GMT +2. The time now is 08:30.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.