我尝试添加保存在txt文件中的mailadresses,每行一个,使用以下代码
<?php
require 'soap_config.php';
$datei = "address.txt"; // Name der Datei
$adresse = file($datei); // Datei in ein Array einlesen
$client = new SoapClient(null, array('location' => $soap_location,
'uri' => $soap_uri,
'trace' => 1,
'exceptions' => 1));
try {
if($session_id = $client->login($username, $password)) {
echo 'Logged successfull. Session ID:'.$session_id.'<br />';
}
foreach ($adresse as $zeile)
{
//* Set the function parameters.
$client_id = 1;
$params = array(
'server_id' => 1,
'email' => $zeile,
'login' => $zeile,
'password' => 'Password1!',
'name' => $zeile,
'uid' => 5000,
'gid' => 5000,
'maildir' => '/var/vmail/domain.tld/'.$zeile,
'quota' => 268435456,
'cc' => '',
'homedir' => '/var/vmail',
'autoresponder' => 'n',
'autoresponder_start_date' => array('day' => 1, 'month' => 7, 'year' => 2012, 'hour' => 0, 'minute' => 0),
'autoresponder_end_date' => array('day' => 20, 'month' => 7, 'year' => 2012, 'hour' => 0, 'minute' => 0),
'autoresponder_text' => 'hallo',
'move_junk' => 'y',
'custom_mailfilter' => '',
'postfix' => 'y',
'access' => 'n',
'disableimap' => 'n',
'disablepop3' => 'y',
'disabledeliver' => 'n',
'disablesmtp' => 'n'
);
$affected_rows = $client->mail_user_add($session_id, $client_id, $params);
echo "New user: ".$affected_rows."<br>";
}
if($client->logout($session_id)) {
echo 'Logged out.<br />';
}
} catch (SoapFault $e) {
echo $client->__getLastResponse();
die('SOAP Error: '.$e->getMessage());
};
?>
如果我运行此代码,我总是会收到以下错误
Logged successfull. Session ID:83f678adsafa9f37b5qw47rrf73c3a97<br /><?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault> <faultcode>mail_domain_does_not_exist</faultcode><faultstring>Mail domain - domain.tld - does not exist.</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> SOAP Error: Mail domain - domain.tld
如果我只是尝试通过将其写入soap文件来添加地址,那么一切正常。我可能错过了哪些想法?