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
51 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

Fine Tune your automatic Updates for Ubuntu / Debian
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Suggested Courses

636 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