Route emails locally for the same domain
Hi there,
I have found that even my local emails are being sent out of my server and then are routed back to this domain, how can I route emails locally for my domain [example.com] to reside on the same server and the attachments if any are not duplicated either in this case are rather shared through "symbolic links".
If someone can share a Script for WHM to route emails locally for the same domain, that will be great. I did try this script but failed on two accounts
- it failed to fetch 'dig' command failed to fetch any MX record [even though when executed directly, it succeeds]
- I am using CentOS v7.9.2009 STANDARD cPanel v $transport_file
# Update the transport map
postmap $transport_file
# Configure Postfix to use Maildir format and create symbolic links for attachments
main_cf="/etc/postfix/main.cf"
attachments_dir="/var/mail/attachments"
# Add or update the configuration in main.cf
echo "
# Configure Postfix to use Maildir format and symbolic links for attachments
home_mailbox = Maildir/
maildir_copy = no
mime_directory = $attachments_dir
" >> $main_cf
# Create the attachments directory
mkdir -p $attachments_dir
# Set permissions for the attachments directory
chown -R postfix:postfix $attachments_dir
# Restart the Postfix service
service postfix restart
echo "Email routing for $domain has been configured to route locally."
echo "Attachments will be shared using symbolic links."
` I will appreciate any assistance to get this resolved. Thanks and Regards,
-
Hey there! cPanel doesn't use Postfix, so the code you provided wouldn't be helpful on a cPanel machine. The setting you likely need to adjust is inside cPanel >> Email Routing for the affected domain. Just ensure that is set to the "Local mail exchanger" option and then system will deliver the messages locally. 0 -
Thanks for your reply @cPRex, yes that's what I have concluded as well. I have set cPanel >> Email Routing to "Automatic", hope that's equally good? I was wondering if there's a way to "not to duplicate" the attachments when they are sent to an email address of the same `domain`, and instead the same `attachment` is shared through a Symbolic Link. Keenly awaiting for your response? Thanks again! 0 -
Automatic should be just fine as well. Are you saying that if one email with an attachment is sent to user1@domain.com and also user2@domain.com that you'd like the attachment to only physically exist in one spot on the server and the others are a link to it? I'm assuming the goal is to save disk space, but I don't believe that is possible in a standard email environment because each email user is limited to their own directory structure. There isn't a "public" area like you could create with FTP. 0 -
Automatic should be just fine as well. Are you saying that if one email with an attachment is sent to user1@domain.com and also user2@domain.com that you'd like the attachment to only physically exist in one spot on the server and the others are a link to it? I'm assuming the goal is to save disk space, but I don't believe that is possible in a standard email environment because each email user is limited to their own directory structure. There isn't a "public" area like you could create with FTP.
I wouldn't mind this a bit either, what actually I was asking was that "if user1@domain.com sends an email to user2@domain.com and user3@domain.com and it does contain an attachment as well is being sent and received on the same domain]" that attachment should be shared amongst the users through a "Symbolic Link"?0 -
Right, I think we're saying the same thing just in different words. Unfortunately, I'm not aware of a way to do that and I didn't find anything like that in the Exim documentation when looked there either. 0 -
Right, I think we're saying the same thing just in different words. Unfortunately, I'm not aware of a way to do that and I didn't find anything like that in the Exim documentation when looked there either.
Hmm .. thanks for you support though.0
Please sign in to leave a comment.
Comments
6 comments