Solved

EXIM: How can I route emails originating from a PHP script through an IP, and emails from SMTP/IMAP through another IP?

Posted on 2016-08-23
4
27 Views
Last Modified: 2016-09-14
Hi,

Is it possible to make exim route all email originating from php scripts (/usr/sbin/sendmail) through RouteA, and route all email originating from smtp/imap connections through RouteB?

I'm running exim on a cpanel server, and every email originated from PHP scripts have a header called "X-PHP-Script". Is it possible to make exim filter emails that have this header and deliver these emails using a particular IP on my server?

Thank you
0
Comment
Question by:Vinicius Munich
  • 3
4 Comments
 
LVL 40

Accepted Solution

by:
noci earned 500 total points (awarded by participants)
ID: 41769354
You can configure exim to listen for 127.0.0.1:1125   (choose any port you like just not a regular one).
And configure sending your PHP apps to send SMTP to this port.
In a router you can filter on the source port. (For a good example check out the amavisd / exim configurations, there the default router picks up mail, forwards it to amavis and the receives again from amavis for normal processing...)
1
 

Author Comment

by:Vinicius Munich
ID: 41769860
Thanks for the suggestion @noci. Unfortunately that wouldn't work for me. I run a small shared hosting, and often users will use outdated or vulnerable scripts, so they get abused. Attackers might upload or run scripts that sends a lot of spam.

Since these spamming PHP scripts use /usr/sbin/sendmail to send email, I can't force them to use a custom port. I'm trying to route email sent using /usr/sbin/sendmail through one route and SMTP email through another route so that if RouteA gets blacklisted because of spammers, it won't affect the emails sent from SMTP, because it uses RouteB.

It doesn't have to be routes necessarily. If I could send email from php scripts through one IP, and SMTP email through another IP, that would work too.

Would you have another suggestion?

Thank you
0
 
LVL 40

Assisted Solution

by:noci
noci earned 500 total points (awarded by participants)
ID: 41770637
You can allways replace /usr/sbin/sendmail with a script that does nothing.... or just log, or rings alarmbells.
And have the legit scripts send mail through localhost on a specific, non SMTP related  port.

Sendmail only is a symbolic link to exim but it can be any script.
Also check /usr/lib/sendmail though.... should also be a symlink to /usr/sbin/sendmail
1
 
LVL 40

Expert Comment

by:noci
ID: 41797502
Sufficient info in both answers
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
This Micro Tutorial demonstrates  how Internet marketers work with competitive analysis data, and a common task in data preparation is creating separate column for domains. You will then extract from a list of URLs.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now