Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
82 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 2000 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 2000 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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
Steps to fix error: “Couldn’t mount the database that you specified. Specified database: HU-DB; Error code: An Active Manager operation fail”
In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

824 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