PHP mail function

4 posts / 0 new
Last post
#1 Sun, 04/24/2016 - 00:23
hinhthoi

PHP mail function

Hi,

In a default virtualmin installation, i'd like to ask what are the ways that a normal user can send email? I'm aware that mail() can be used in php, so is there any other way? The reason is if a user send an unsolicited email from my server, i need to know the way they send, so that i can prevent them from sending further.

Alternatively, it is great if there is a mail rate limiting feature in virtualmin, but i prefer it to limit per virtual server (no matter how many users/subusers each virtual server has), not the global limit.

Thanks for any help !

Sun, 04/24/2016 - 08:06
andreychek

Howdy,

Well, it would be fairly difficult to completely prevent users from sending mail. The PHP mail() function is a common way to do that. But any program or code is able to communicate with Postfix on port 25.

In the case of PHP's mail function, that just simplifies things a bit.

There is an email rate limiting feature in Email Messages -> Email Rate Limiting. I think that's available on both Virtualmin Pro and GPL.

-Eric

Sun, 04/24/2016 - 10:10
hinhthoi

Thanks Eric for your help. I got the following in the mail.log file after enabling the global rate limit. After deactivate the feature, they donot appear in the log file again. Is this a bug? Thanks!

Apr 24 11:04:20 server2 postfix/smtpd[24131]: connect from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:20 server2 milter-greylist: smfi_getsymval failed for {i}
Apr 24 11:04:20 server2 milter-greylist: ratelimit overflow for class virtualmin_limit: 10539, limit is 30 recipients / 3600 sec, key = "63.142.248.100"
Apr 24 11:04:20 server2 milter-greylist: (unknown id): addr server2.dollarhosting.xyz[63.142.248.100] from <support@dollarhosting.xyz> to <viforcom@gmail.com> blacklisted (ACL 74)
Apr 24 11:04:20 server2 postfix/smtpd[24131]: NOQUEUE: milter-reject: RCPT from server2.dollarhosting.xyz[63.142.248.100]: 551 5.7.1 Message quota exceeded; from=<support@dollarhosting.xyz> to=<viforcom@gmail.com> proto=ESMTP helo=<localhost.localdomain>
Apr 24 11:04:20 server2 postfix/smtpd[24131]: lost connection after RCPT from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:20 server2 postfix/smtpd[24131]: disconnect from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:20 server2 postfix/smtpd[24131]: connect from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:20 server2 postfix/postfix-script[24275]: refreshing the Postfix mail system
Apr 24 11:04:20 server2 postfix/master[24063]: reload -- version 2.11.0, configuration /etc/postfix
Apr 24 11:04:20 server2 postfix/anvil[24071]: statistics: max connection rate 787/60s for (smtp:63.142.248.100) at Apr 24 11:04:20
Apr 24 11:04:20 server2 postfix/anvil[24071]: statistics: max connection count 1 for (smtp:63.142.248.100) at Apr 24 11:03:24
Apr 24 11:04:20 server2 postfix/anvil[24071]: statistics: max cache size 1 at Apr 24 11:03:24
Apr 24 11:04:20 server2 milter-greylist: smfi_getsymval failed for {i}
Apr 24 11:04:20 server2 milter-greylist: ratelimit overflow for class virtualmin_limit: 10540, limit is 30 recipients / 3600 sec, key = "63.142.248.100"
Apr 24 11:04:20 server2 milter-greylist: (unknown id): addr server2.dollarhosting.xyz[63.142.248.100] from <support@dollarhosting.xyz> to <viforcom@gmail.com> blacklisted (ACL 74)
Apr 24 11:04:20 server2 postfix/smtpd[24131]: NOQUEUE: milter-reject: RCPT from server2.dollarhosting.xyz[63.142.248.100]: 551 5.7.1 Message quota exceeded; from=<support@dollarhosting.xyz> to=<viforcom@gmail.com> proto=ESMTP helo=<localhost.localdomain>
Apr 24 11:04:20 server2 postfix/smtpd[24289]: connect from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:22 server2 postfix/smtpd[24131]: lost connection after RCPT from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:22 server2 postfix/smtpd[24131]: disconnect from server2.dollarhosting.xyz[63.142.248.100]
Apr 24 11:04:22 server2 milter-greylist: greylist: private data not NULL
Apr 24 11:04:22 server2 postfix/smtpd[24289]: 6C6EC737C4E81: client=server2.dollarhosting.xyz[63.142.248.100], sasl_method=LOGIN, sasl_username=dollarhosting
Apr 24 11:04:22 server2 postfix/cleanup[24299]: 6C6EC737C4E81: message-id=<691706660e3773484a1e9a42349e6af1@localhost.localdomain>
Apr 24 11:04:22 server2 postfix/qmgr[24281]: 6C6EC737C4E81: from=<support@dollarhosting.xyz>, size=1782, nrcpt=1 (queue active)
Apr 24 11:04:22 server2 postfix/smtpd[24289]: disconnect from server2.dollarhosting.xyz[63.142.248.100]
Sun, 04/24/2016 - 10:44
hinhthoi

When i set the Global rate limit to be 1, my second test email was put in queue because of the quota limit.

When postfix see a mail in queue, it automatically retry to make connection, and all of those attempts was stopped by the Global rate limit, and the email is still in the queue, and postfix generates connections again. And that cycle going on and on.

My ISP blocked port 25 because of the many connections. Is this the correct thing that is happening?

Thanks!

Topic locked