LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How do I setup postfix to act as an email client, so when I send mail to it, it goes through another server? (https://www.linuxquestions.org/questions/linux-server-73/how-do-i-setup-postfix-to-act-as-an-email-client-so-when-i-send-mail-to-it-it-goes-through-another-server-4175711793/)

Red Squirrel 05-07-2022 01:56 AM

How do I setup postfix to act as an email client, so when I send mail to it, it goes through another server?
 
Basically I want to make it so that if I use the mail command or otherwise send an email via the local mail server, it actually goes through an external mail server. Basically I need to be able to send email from a local computer but I don't want it to keep getting marked as spam because it's coming directly from the computer.

I currently don't have a mail server setup myself online but do have a shared host, so trying to route mail through there. I found a tutorial on how to do it and ended up with the following config in mail.conf:

Code:

relayhost = [sharedhost]:465
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/postfix/certificate.pem
smtp_use_tls = yes

I also created the sasl_passwd file as follows:

Code:

[shardhost]:465 username:password
I then ran postmap command on that file.

However when I try to send an email I end up with an error in the log:

Code:

(delivery temporarily suspended: lost connection with sharedhost[1.2.3.4] while receiving the initial server greeting)
So something is still wrong. Any other parameter or step I may have missed?

evo2 05-07-2022 02:13 AM

Hi,

any particular reason you are using postfix? exim4 is the default mta on Debian and can be easily configured to do this (send via a smarthost).

Evo2.

Red Squirrel 05-07-2022 02:35 AM

It's already setup so it's just easier and that's what I've always used so I'm at least a tad familiar with it. This is an old CentOS 6.10 box that's no longer being updated (the yum repos are dead) so trying to install something else would be more of a pain than it's worth.

Though if it's not easy to do, my plan B is to modify my application to use a separate client like mailx instead of connecting to the local server directly. From quick google search it looks like I can specify external mail server with that command. So rather than have my app send the mail directly to localhost via tcp socket I can just have it write to a file and then have a separate script that looks for files then uses mailx to send the mail.

evo2 05-07-2022 04:35 AM

Quote:

Originally Posted by Red Squirrel (Post 6351324)
It's already setup so it's just easier and that's what I've always used so I'm at least a tad familiar with it. This is an old CentOS 6.10 box that's no longer being updated (the yum repos are dead) so trying to install something else would be more of a pain than it's worth.

Ahh, ok. You didn't say what OS this was, and your profile only lists Debian (and a derivative) so assumed that is what you were using.

Evo2.

Red Squirrel 05-07-2022 06:19 PM

Yeah forgot to mention, I guess the config syntax, file locations etc does change a lot between distros.


All times are GMT -5. The time now is 04:38 PM.