Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Migration

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-30-2009, 08:32 AM
Member
 
Posts: 12
Question [SOLVED] Import with Rest Links

Hi, i've made a rfc822txt file exporting from my imap account to that file all emails from one account.

I try to import using the rest link curl -u schemersassword --data-binary ..... etc

but it still don't work. By the way what is the schemers? the user?

Can i import this file in another way?.

I saw that it can only import .eml files from admin... are there alternative ways?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 03-30-2009, 08:48 AM
Zimbra Consultant & Moderator
 
Posts: 20,317
Default

I presume you've used this example from the wiki?

Code:
 curl -u schemers:password --data-binary @/tmp/rfc822.txt https://server/service/home/schemers/inbox
In this example 'schemers' is the username and password would be the password for that user account.
__________________
Regards


Bill
Reply With Quote
  #3 (permalink)  
Old 03-30-2009, 12:35 PM
Member
 
Posts: 12
Default

OK, i see phoenix... I try to import using the admin panel and make a single rfc822 file containing 250 emails, but when using import from the admin panel it says that the import is ok but the emails aren't where they suppose to be. Is there another step between or must I import only .eml files in a tar.gz?


Thanks.
Reply With Quote
  #4 (permalink)  
Old 03-30-2009, 02:44 PM
Moderator
 
Posts: 6,237
Default

Use --upload-file instead of --data-binary (we seem to not support the latter very well anymore, I'll file a bug so we keep it available - especially with lots of old examples around).

Plus you need to get it out of mbox format first, else it's only gonna only see the first message.
There are 3 scripts that will do that here (or you can go mbox to mailbox format then into Zimbra): User Migration - Zimbra :: Wiki

You can also install an extension such as ImportExportTools so you can import mbox or .eml into Thunderbird > connect via IMAP > move/copy to Zimbra.

Example:
Code:
curl -u user@domain.com:password --upload-file /opt/zimbra/test/A http://server//home/user@domain.com/inbox
In paths 'user' & 'home', as well as 'service' & 'zimbra' (your zimbraMailURL) are mostly interchangeabl / often not needed. You can construct in a variety of ways, ie:
/user/~
/home/accountname
/zimbra/user/~/
/zimbra/home/~/
/zimbra/user/accountnamehere/
/zimbra/home/accountnameehere/
/service/home/~

If you get connections errors make sure your mode (http vs https) matches your configuration: CLI zmtlsctl to set Web Server Mode - Zimbra :: Wiki
Reply With Quote
  #5 (permalink)  
Old 03-30-2009, 03:15 PM
Moderator
 
Posts: 6,237
Default

Actually --data-binary will still work for messages if you remember to use the @ symbol (else it comes in as a blank msg).
Code:
curl -u user@domain.com:pass --data-binary @/opt/zimbra/test/A http://server/home/user@domain.com/inbox
(You still need to pass messages in separated, not one big file.)


However --data-binary doesn't seem to work for contacts anymore (with or without the @):
Code:
#curl -u user@domain.com:pass --upload-file /opt/zimbra/test/Contacts.csv http://server/home/user@domain.com/Contacts?fmt=csv
Works. While:
Code:
#curl -u user@domain.com:pass --data-binary /opt/zimbra/test/Contacts.csv http://server/home/user@domain.com/Contacts?fmt=csv
or
#curl -u user@domain.com:pass --data-binary @/opt/zimbra/test/Contacts.csv http://server/home/user@domain.com/Contacts?fmt=csv
Results in:
Quote:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 400 </title>
</head>
<body><h2>HTTP ERROR: 400</h2><pre>could not parse csv file</pre>
<p>RequestURI=/service/home/user@domain.com/Contacts</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>
<br/>
</body>
</html>
Reply With Quote
  #6 (permalink)  
Old 04-01-2009, 02:03 AM
Member
 
Posts: 12
Smile

Ok, guys a little help for migrating (clone) from server A to a zimbra server B using a simple yet effective PHP script. It copies al folders and subfolders too.

It connects via imap to server A and clone it using imap with zimbra server B... it's a little slowly, so be patient

<?php

if($_POST["Submit"] != '')
{
ini_set('max_execution_time',0);
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 'On');
ini_set('display_startup_errors','On');

# open connection to obtain list of folders
$mbox_origen = imap_open("{{$_POST["servidor"]}:143/notls}INBOX", $_POST["email"], $_POST["passw"], OP_HALFOPEN);
$list = imap_list($mbox_origen,"{{$_POST["server"]}}","*");

imap_close($mbox_origen);

for($c=0;$c<count($list);$c++)
{
# we cut the string to obtain folder name
$conexion = explode("}",$list[$c]);

# construct the string connection to imap server A (a single imap server to 143 with notls flag)
$string = $conexion[0].":143/notls}".$conexion[1];

$mbox_origen = imap_open($string, $_POST["email"], $_POST["passw"]);

# obtain the folder from server A
$carpeta = explode("}INBOX",$list[$c]);

if($carpeta[1]!='')
{
# from the folder name bring out the dot from the name
$carpeta_destino = substr($carpeta[1],strpos($carpeta[1],".")+1,strlen($carpeta[1]));

# connect to the zimbra server
$mbox_destino = imap_open("{{$_POST["destiny_server"]}}", $_POST["destiny_email"], $_POST["destiny_passw"]);

# create the folder in the zimbra server
imap_createmailbox($mbox_destino, imap_utf7_encode("{{$_POST["destiny_server"]}}".$carpeta_destino));

# if inbox connecto to it in zimbra
}else {
# abrimos imap con link a inbox
$mbox_destino = imap_open("{{$_POST["destiny_server"]}}INBOX", $_POST["destiny_email"], $_POST["destiny_passw"]);
}

# get num of mssgs
$numero_mensajes = imap_num_msg($mbox_origen);

for($i=1;$i<$numero_mensajes;$i++)
{

# create the email string to apped
$header = imap_fetchheader($mbox_origen,$i);
$cuerpo = imap_body($mbox_origen,$i);
$mail = $header."\n".$cuerpo;

# append it!
($carpeta[1]!='') ? imap_append($mbox_destino,"{{$_POST["destiny_server"]}}".$carpeta_destino,$mail) : imap_append($mbox_destino,"{{$_POST["destiny_server"]}}INBOX",$mail);

}
imap_close($mbox_destino);
imap_close($mbox_origen);

}
print "<br><b>Clonation ends!</b>...<br>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
body {
margin-top: 130px;
background-color: #FFFFFF;
}
.Estilo4 {font-size: 16px}
.Estilo6 {
font-size: 16px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FF0000;
}
.Estilo7 {font-size: 12px}
.Estilo8 {font-size: 14px; }
.Estilo9 {font-size: 14px; font-weight: bold; }
-->
</style></head>
<body>
<center>
<form action="imap_harvester.php" method="POST">
<table width="514" border="0" cellpadding="0" cellspacing="3" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td width="508" height="289" valign="top">
<fieldset>
<legend>Zimbra Email <strong>Harvester</strong>&nbsp;&nbsp;</legend>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#DDDCBF">
<!--DWLayoutTable-->
<tr>
<td height="36" colspan="6" align="right" valign="top"><span class="Estilo4">isl<span class="Estilo6">@</span>mail</span></td>
</tr>
<tr>
<td height="22" colspan="2" align="right" valign="middle" class="Estilo9">From Server : </td>
<td colspan="2" align="left" valign="middle">
<input name="server" type="text" id="server" value="mail2.islared.com" /></td>
<td colspan="2" align="left" valign="middle"><span class="Estilo7">(example: mail.domain.com)</span></td>
</tr>
<tr>
<td width="17" height="3"></td>
<td width="167"></td>
<td width="144"></td>
<td width="5"></td>
<td width="125"></td>
<td width="41"></td>
</tr>
<tr>
<td height="22"></td>
<td align="right" valign="middle" class="Estilo9">Email : </td>
<td colspan="3" align="left" valign="middle"><input name="email" type="text" id="email" /></td>
<td></td>
</tr>
<tr>
<td height="3"></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle" class="Estilo9">Passw : </td>
<td colspan="3" align="left" valign="middle"><input name="passw" type="password" id="passw"/></td>
<td></td>
</tr>
<tr>
<td height="22" colspan="6" align="center" valign="middle"><hr /></td>
</tr>
<tr>
<td height="22" colspan="2" align="right" valign="middle" class="Estilo9">To Server (zimbra): </td>
<td align="left" valign="middle">
<input name="destiny_server" type="text" id="destiny_server" value="<zimbra_server:993/imap/ssl/notls/novalidate-cert" /> </td>
<td colspan="3" rowspan="2" align="left" valign="middle"><span class="Estilo7">(example: mail.domain.com)</span></td>
</tr>
<tr>
<td height="3"></td>
<td></td>
<td></td>
</tr>

<tr>
<td height="22"></td>
<td align="right" valign="middle" class="Estilo9">Email : </td>
<td colspan="3" rowspan="2" align="left" valign="middle"><input name="destiny_email" type="text" id="destiny_email" /></td>
<td></td>
</tr>
<tr>
<td height="4"></td>
<td></td>
<td></td>
</tr>


<tr>
<td height="23"></td>
<td align="right" valign="middle" class="Estilo9">Passw: </td>
<td colspan="3" align="left" valign="middle"><input name="destiny_passw" type="password" id="destiny_passw"/></td>
<td></td>
</tr>
<tr>
<td height="61"></td>
<td colspan="4" align="center" valign="middle"><label>
<input type="submit" name="Submit" value=" Clone It " />
</label></td>
<td></td>
</tr>
</table>
</fieldset></td>
</tr>
</table>
</form>
</center>
</body>
</html>

Last edited by ajflorido; 04-01-2009 at 07:22 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.