Sendmail migration: Replicating all incoming mails to another mailserver











up vote
1
down vote

favorite












I am migrating a mailserver running sendmail 8.14.3 to a postfix server. The MDA on the new server is Dovecot. In order to ensure a seamless transition, it would be best if incoming mails are delivered to both servers simultaneously.



I've heard about the SMART_HOST and nullcient options in sendmail, but I'm not sure if this works in the way I need it to. What I need is all incoming mails also delivered to the new server, leaving the existing configuration untouched, as they should be delivered to the mailboxes on the old server as well.



Mails are sent to an address like test@mydomain.com and should be delivered to mx1.mydomain.com (old) and mx2.mydomain.com (new). So mx1 should forward a copy to mx2.



Dual MX Records are not enough as the one server would only be contacted when the other one isn't reachable - while both should be receiving the mail.



Maybe another option would be to configure sendmail to deliver directly to Dovecot on the new server via lmtp? Or maybe just rsync the mailboxes on the two servers. But I'm not sure if that's compatible.



UPDATE: It's not the same format: on the old server, there are just plain old files for each mailbox, while Dovecot creates a cur, new tmp structure in each user's mail directory. However, in the end, files with a similar format reside in those directories. The speration string is different though. Maybe it's possible to translate the old format and copy it to the new server periodically? Would that somehow interfere with Dovecot? And where could I place the copies on the new server so that Dovecot won't be affected while still recognising them?



I hope there is some kind of workaround for that.





System Indormation



Number of mailboxes: ~100-200



Old Server:



OS: Debian GNU/Linux 6.0
sendmail 8.14.3
mails are delivered to "real"/"passwd" users
Other Serives: apache2, mysql, other miscellaneous


New Server:



OS: Debian GNU/Linux 9
postfix
dovecot
mails are delivered to virtual users/SQL
Other services: apache2, mysql, other miscellaneous


Current MX entry for reference:



mydomain.com.    IN      MX      0 mx1.mydomain.com.
mydomain.com. IN MX 1 mx2.mydomain.com.









share|improve this question
























  • This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
    – roaima
    7 hours ago















up vote
1
down vote

favorite












I am migrating a mailserver running sendmail 8.14.3 to a postfix server. The MDA on the new server is Dovecot. In order to ensure a seamless transition, it would be best if incoming mails are delivered to both servers simultaneously.



I've heard about the SMART_HOST and nullcient options in sendmail, but I'm not sure if this works in the way I need it to. What I need is all incoming mails also delivered to the new server, leaving the existing configuration untouched, as they should be delivered to the mailboxes on the old server as well.



Mails are sent to an address like test@mydomain.com and should be delivered to mx1.mydomain.com (old) and mx2.mydomain.com (new). So mx1 should forward a copy to mx2.



Dual MX Records are not enough as the one server would only be contacted when the other one isn't reachable - while both should be receiving the mail.



Maybe another option would be to configure sendmail to deliver directly to Dovecot on the new server via lmtp? Or maybe just rsync the mailboxes on the two servers. But I'm not sure if that's compatible.



UPDATE: It's not the same format: on the old server, there are just plain old files for each mailbox, while Dovecot creates a cur, new tmp structure in each user's mail directory. However, in the end, files with a similar format reside in those directories. The speration string is different though. Maybe it's possible to translate the old format and copy it to the new server periodically? Would that somehow interfere with Dovecot? And where could I place the copies on the new server so that Dovecot won't be affected while still recognising them?



I hope there is some kind of workaround for that.





System Indormation



Number of mailboxes: ~100-200



Old Server:



OS: Debian GNU/Linux 6.0
sendmail 8.14.3
mails are delivered to "real"/"passwd" users
Other Serives: apache2, mysql, other miscellaneous


New Server:



OS: Debian GNU/Linux 9
postfix
dovecot
mails are delivered to virtual users/SQL
Other services: apache2, mysql, other miscellaneous


Current MX entry for reference:



mydomain.com.    IN      MX      0 mx1.mydomain.com.
mydomain.com. IN MX 1 mx2.mydomain.com.









share|improve this question
























  • This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
    – roaima
    7 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am migrating a mailserver running sendmail 8.14.3 to a postfix server. The MDA on the new server is Dovecot. In order to ensure a seamless transition, it would be best if incoming mails are delivered to both servers simultaneously.



I've heard about the SMART_HOST and nullcient options in sendmail, but I'm not sure if this works in the way I need it to. What I need is all incoming mails also delivered to the new server, leaving the existing configuration untouched, as they should be delivered to the mailboxes on the old server as well.



Mails are sent to an address like test@mydomain.com and should be delivered to mx1.mydomain.com (old) and mx2.mydomain.com (new). So mx1 should forward a copy to mx2.



Dual MX Records are not enough as the one server would only be contacted when the other one isn't reachable - while both should be receiving the mail.



Maybe another option would be to configure sendmail to deliver directly to Dovecot on the new server via lmtp? Or maybe just rsync the mailboxes on the two servers. But I'm not sure if that's compatible.



UPDATE: It's not the same format: on the old server, there are just plain old files for each mailbox, while Dovecot creates a cur, new tmp structure in each user's mail directory. However, in the end, files with a similar format reside in those directories. The speration string is different though. Maybe it's possible to translate the old format and copy it to the new server periodically? Would that somehow interfere with Dovecot? And where could I place the copies on the new server so that Dovecot won't be affected while still recognising them?



I hope there is some kind of workaround for that.





System Indormation



Number of mailboxes: ~100-200



Old Server:



OS: Debian GNU/Linux 6.0
sendmail 8.14.3
mails are delivered to "real"/"passwd" users
Other Serives: apache2, mysql, other miscellaneous


New Server:



OS: Debian GNU/Linux 9
postfix
dovecot
mails are delivered to virtual users/SQL
Other services: apache2, mysql, other miscellaneous


Current MX entry for reference:



mydomain.com.    IN      MX      0 mx1.mydomain.com.
mydomain.com. IN MX 1 mx2.mydomain.com.









share|improve this question















I am migrating a mailserver running sendmail 8.14.3 to a postfix server. The MDA on the new server is Dovecot. In order to ensure a seamless transition, it would be best if incoming mails are delivered to both servers simultaneously.



I've heard about the SMART_HOST and nullcient options in sendmail, but I'm not sure if this works in the way I need it to. What I need is all incoming mails also delivered to the new server, leaving the existing configuration untouched, as they should be delivered to the mailboxes on the old server as well.



Mails are sent to an address like test@mydomain.com and should be delivered to mx1.mydomain.com (old) and mx2.mydomain.com (new). So mx1 should forward a copy to mx2.



Dual MX Records are not enough as the one server would only be contacted when the other one isn't reachable - while both should be receiving the mail.



Maybe another option would be to configure sendmail to deliver directly to Dovecot on the new server via lmtp? Or maybe just rsync the mailboxes on the two servers. But I'm not sure if that's compatible.



UPDATE: It's not the same format: on the old server, there are just plain old files for each mailbox, while Dovecot creates a cur, new tmp structure in each user's mail directory. However, in the end, files with a similar format reside in those directories. The speration string is different though. Maybe it's possible to translate the old format and copy it to the new server periodically? Would that somehow interfere with Dovecot? And where could I place the copies on the new server so that Dovecot won't be affected while still recognising them?



I hope there is some kind of workaround for that.





System Indormation



Number of mailboxes: ~100-200



Old Server:



OS: Debian GNU/Linux 6.0
sendmail 8.14.3
mails are delivered to "real"/"passwd" users
Other Serives: apache2, mysql, other miscellaneous


New Server:



OS: Debian GNU/Linux 9
postfix
dovecot
mails are delivered to virtual users/SQL
Other services: apache2, mysql, other miscellaneous


Current MX entry for reference:



mydomain.com.    IN      MX      0 mx1.mydomain.com.
mydomain.com. IN MX 1 mx2.mydomain.com.






email postfix sendmail






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 6 hours ago

























asked Dec 14 at 17:48









rudib

439316




439316












  • This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
    – roaima
    7 hours ago


















  • This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
    – roaima
    7 hours ago
















This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
– roaima
7 hours ago




This isn't so much redirection as replication of incoming emails. Redirection could be handled at the MX level. Replication is harder.
– roaima
7 hours ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted
+50










I can't test this right now but I'm fairly sure sendmail understands entries in /etc/aliases of the form



fred: fred, fred@otherserver


(If it goes into a mad loop, prefix the second fred with a backslash .)



Then it's a straightforward extract from /etc/passwd into the aliases file. And remember to run newaliases (?) to update the internal sendmail database.



Here is an example snippet to generate the lines that would be appended. It considers only users whose UID is in the range { 1000 ≤ uid < 65000 }.



[ ! -f /etc/aliases.save ] && cp -p /etc/aliases /etc/aliases.save

(
cat /etc/aliases.save
echo
getent passwd |
awk -F: '$3>=1000 && $3<65000 {printf "%s: %s, %s@mx2.mydomain.comn", $1, $1, $1}'
) >/etc/aliases

newaliases





share|improve this answer























  • I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
    – rudib
    6 hours ago










  • Or would the new server just accept something like fred@mx2.mydomain.com?
    – rudib
    6 hours ago










  • If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
    – roaima
    6 hours ago












  • I've updated my question with sample mx records to hopefully clarify what I mean by that.
    – rudib
    6 hours ago






  • 1




    I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
    – rudib
    5 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f488034%2fsendmail-migration-replicating-all-incoming-mails-to-another-mailserver%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted
+50










I can't test this right now but I'm fairly sure sendmail understands entries in /etc/aliases of the form



fred: fred, fred@otherserver


(If it goes into a mad loop, prefix the second fred with a backslash .)



Then it's a straightforward extract from /etc/passwd into the aliases file. And remember to run newaliases (?) to update the internal sendmail database.



Here is an example snippet to generate the lines that would be appended. It considers only users whose UID is in the range { 1000 ≤ uid < 65000 }.



[ ! -f /etc/aliases.save ] && cp -p /etc/aliases /etc/aliases.save

(
cat /etc/aliases.save
echo
getent passwd |
awk -F: '$3>=1000 && $3<65000 {printf "%s: %s, %s@mx2.mydomain.comn", $1, $1, $1}'
) >/etc/aliases

newaliases





share|improve this answer























  • I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
    – rudib
    6 hours ago










  • Or would the new server just accept something like fred@mx2.mydomain.com?
    – rudib
    6 hours ago










  • If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
    – roaima
    6 hours ago












  • I've updated my question with sample mx records to hopefully clarify what I mean by that.
    – rudib
    6 hours ago






  • 1




    I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
    – rudib
    5 hours ago















up vote
1
down vote



accepted
+50










I can't test this right now but I'm fairly sure sendmail understands entries in /etc/aliases of the form



fred: fred, fred@otherserver


(If it goes into a mad loop, prefix the second fred with a backslash .)



Then it's a straightforward extract from /etc/passwd into the aliases file. And remember to run newaliases (?) to update the internal sendmail database.



Here is an example snippet to generate the lines that would be appended. It considers only users whose UID is in the range { 1000 ≤ uid < 65000 }.



[ ! -f /etc/aliases.save ] && cp -p /etc/aliases /etc/aliases.save

(
cat /etc/aliases.save
echo
getent passwd |
awk -F: '$3>=1000 && $3<65000 {printf "%s: %s, %s@mx2.mydomain.comn", $1, $1, $1}'
) >/etc/aliases

newaliases





share|improve this answer























  • I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
    – rudib
    6 hours ago










  • Or would the new server just accept something like fred@mx2.mydomain.com?
    – rudib
    6 hours ago










  • If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
    – roaima
    6 hours ago












  • I've updated my question with sample mx records to hopefully clarify what I mean by that.
    – rudib
    6 hours ago






  • 1




    I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
    – rudib
    5 hours ago













up vote
1
down vote



accepted
+50







up vote
1
down vote



accepted
+50




+50




I can't test this right now but I'm fairly sure sendmail understands entries in /etc/aliases of the form



fred: fred, fred@otherserver


(If it goes into a mad loop, prefix the second fred with a backslash .)



Then it's a straightforward extract from /etc/passwd into the aliases file. And remember to run newaliases (?) to update the internal sendmail database.



Here is an example snippet to generate the lines that would be appended. It considers only users whose UID is in the range { 1000 ≤ uid < 65000 }.



[ ! -f /etc/aliases.save ] && cp -p /etc/aliases /etc/aliases.save

(
cat /etc/aliases.save
echo
getent passwd |
awk -F: '$3>=1000 && $3<65000 {printf "%s: %s, %s@mx2.mydomain.comn", $1, $1, $1}'
) >/etc/aliases

newaliases





share|improve this answer














I can't test this right now but I'm fairly sure sendmail understands entries in /etc/aliases of the form



fred: fred, fred@otherserver


(If it goes into a mad loop, prefix the second fred with a backslash .)



Then it's a straightforward extract from /etc/passwd into the aliases file. And remember to run newaliases (?) to update the internal sendmail database.



Here is an example snippet to generate the lines that would be appended. It considers only users whose UID is in the range { 1000 ≤ uid < 65000 }.



[ ! -f /etc/aliases.save ] && cp -p /etc/aliases /etc/aliases.save

(
cat /etc/aliases.save
echo
getent passwd |
awk -F: '$3>=1000 && $3<65000 {printf "%s: %s, %s@mx2.mydomain.comn", $1, $1, $1}'
) >/etc/aliases

newaliases






share|improve this answer














share|improve this answer



share|improve this answer








edited 6 hours ago

























answered 6 hours ago









roaima

42.6k551116




42.6k551116












  • I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
    – rudib
    6 hours ago










  • Or would the new server just accept something like fred@mx2.mydomain.com?
    – rudib
    6 hours ago










  • If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
    – roaima
    6 hours ago












  • I've updated my question with sample mx records to hopefully clarify what I mean by that.
    – rudib
    6 hours ago






  • 1




    I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
    – rudib
    5 hours ago


















  • I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
    – rudib
    6 hours ago










  • Or would the new server just accept something like fred@mx2.mydomain.com?
    – rudib
    6 hours ago










  • If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
    – roaima
    6 hours ago












  • I've updated my question with sample mx records to hopefully clarify what I mean by that.
    – rudib
    6 hours ago






  • 1




    I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
    – rudib
    5 hours ago
















I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
– rudib
6 hours ago




I thought of that, but the other server accepts mail under fred@mydomain.com only (the same as the old server as the addresses are supposed to stay the same). So could I somehow remap that on the new server?
– rudib
6 hours ago












Or would the new server just accept something like fred@mx2.mydomain.com?
– rudib
6 hours ago




Or would the new server just accept something like fred@mx2.mydomain.com?
– rudib
6 hours ago












If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
– roaima
6 hours ago






If it's set up to accept mx2.mydomain.com as an alias for its real target name mydomain.com yes that should work.
– roaima
6 hours ago














I've updated my question with sample mx records to hopefully clarify what I mean by that.
– rudib
6 hours ago




I've updated my question with sample mx records to hopefully clarify what I mean by that.
– rudib
6 hours ago




1




1




I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
– rudib
5 hours ago




I think it's working properly now. The old sendmail server may be a bit misconfigured. I've added the old server's ip to mynetworks in postfix. Many thanks for your patience! :)
– rudib
5 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f488034%2fsendmail-migration-replicating-all-incoming-mails-to-another-mailserver%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

サソリ

広島県道265号伴広島線

Accessing regular linux commands in Huawei's Dopra Linux