LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to catch outgoing email when using a SMART_HOST relay (https://www.linuxquestions.org/questions/linux-server-73/how-to-catch-outgoing-email-when-using-a-smart_host-relay-4175736054/)

mfoley 04-15-2024 12:18 PM

How to catch outgoing email when using a SMART_HOST relay
 
Our organization has a website where users can send messages via a Contact Us page.those messages are sent to various recipients. The webserver uses sendmail, but is configures to use the company's Exchange server as the SMART_HOST email relay. Therefore, messages sent from the webpage app (jsp) never route through the local sendmail. I conclude this because I have a bcc-milter which saves a copy of all email to a mail folder and none of the webpape app emails go to this folder.

What can I do to route messages through the local Sendmail server first so Spamassassin can catch and remove the endless stream of messages about Casinos and SEO services?

TB0ne 04-15-2024 04:13 PM

Quote:

Originally Posted by mfoley (Post 6496144)
Our organization has a website where users can send messages via a Contact Us page.those messages are sent to various recipients. The webserver uses sendmail, but is configures to use the company's Exchange server as the SMART_HOST email relay. Therefore, messages sent from the webpage app (jsp) never route through the local sendmail. I conclude this because I have a bcc-milter which saves a copy of all email to a mail folder and none of the webpape app emails go to this folder.

What can I do to route messages through the local Sendmail server first so Spamassassin can catch and remove the endless stream of messages about Casinos and SEO services?

I think you posted your own solution; tell the web page to route to your sendmail server, and point it to the Exchange server to go out.

mfoley 05-02-2024 01:02 PM

I did try that and it sort-of works. However, there's a problem. I do this (sendmail and mailx):
Code:

mail -r joe@xmail.com -s "contact me" contactus < msg.txt
The /etc/mail/aliases file has:
Code:

contactus:      contactus@mydom.org
So, the message to local contactus does route through the webserver sendmail, and does run through the local milters, and does forward to contactus@mydom.org. mydom.org is on MS Exchange, and the message does get delivered to joe@xmail.com. So far so good. The problem is that if the recipients on the contactus.mydom.org distribution list do a Reply-All, the To: addresses end up:
Code:

To: joe@xmail.com; contactus@webserver.hprs.local
The To: address is what happens when routing it through the webserver email. Somehow, I need to be able to change this To: address (originally the sender) to contactus@mydom.org.

mfoley 05-02-2024 01:44 PM

Quote:

Originally Posted by mfoley (Post 6499507)
I did try that and it sort-of works. However, there's a problem. I do this (sendmail and mailx):
Code:

mail -r joe@xmail.com -s "contact me" contactus < msg.txt
The /etc/mail/aliases file has:
Code:

contactus:      contactus@mydom.org
So, the message to local contactus does route through the webserver sendmail, and does run through the local milters, and does forward to contactus@mydom.org. mydom.org is on MS Exchange, and he message does get delivered to joe@xmail.com. So far so good. The problem is that if the recipients on the contactus.mydom.org distribution list do a Reply-All, the To: addresses end up:
Code:

To: joe@xmail.com; contactus@webserver.hprs.local
The To: address is what happens when routing it through the webserver email. Somehow, I need to be able to change this To: address (originally the sender) to contactus@mydom.org.

More info ... I've tried setting .mailrc in the tomcat home directory:
Code:

account portal {
    set from="contactus@mydom.org (Members Website)"
    set hostname=mydom.org
}

set from=contactus@mydom.org

and I've tried manually sending as: mail -A portal -r mfoley@novatec-inc.com -s "test message" contactus < msgBody.txt, but I still generate contactus@webserver.hprs.local when the recipient does a reply-all.

How to change the sender's email address with sendmail?

TB0ne 05-02-2024 02:02 PM

Quote:

Originally Posted by mfoley (Post 6499511)
More info ... I've tried setting .mailrc in the tomcat home directory:
Code:

account portal {
    set from="contactus@mydom.org (Members Website)"
    set hostname=mydom.org
}

set from=contactus@mydom.org

and I've tried manually sending as: mail -A portal -r mfoley@novatec-inc.com -s "test message" contactus < msgBody.txt, but I still generate contactus@webserver.hprs.local when the recipient does a reply-all.

How to change the sender's email address with sendmail?

May want to look into the use of a genericstable: https://www.madboa.com/geek/sendmail-genericstable/

Also, I'd look into the web-code itself, to see how it's sending mail, to see if things can be tweaked there, which may be an easier solution. You might be able to set things there, which would affect only one form/function/page, rather than your entire sendmail server.


All times are GMT -5. The time now is 08:54 AM.