LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sendmail scheduling mail delivery (https://www.linuxquestions.org/questions/linux-newbie-8/sendmail-scheduling-mail-delivery-913788/)

darshakamodi 11-16-2011 02:10 AM

Sendmail scheduling mail delivery
 
Hi,
I have setup Sendmail MTA, my customer sends bulk mailing, due to that we receive error 452, too much mail receipants.
I want to schedule mail in Sendmail, if client has sent mail to 500 receipants, the server will serve in batch of hundres.
Or it will open connection with yahoo/gmail after some time and will deliver message by scheduling it.

How can this be done ??

unSpawn 11-16-2011 06:05 AM

Quote:

Originally Posted by darshakamodi (Post 4525277)
my customer sends bulk mailing, due to that we receive error 452, too much mail receipants. I want to schedule mail in Sendmail, if client has sent mail to 500 receipants, the server will serve in batch of hundres.

In my opinion that would be the wrong approach. Any sane remote MTA your MTA contacts would (or should) see such bulk mail sending as a threat and a violation. So first bursting up to 500 recipients and only after the fact throttle back to 100 may not (should not) cut it. What you enforce should be part customer education and part throttling. For the next please refer to Sendmail documentation and maybe the O'Reilly "Bat book":
- confMAX_RCPTS_PER_MESSAGE: max recipient/message
- confCONNECTION_RATE_THROTTLE: max new connection/second
- confBAD_RCPT_THROTTLE: punish on bad user names
- tune down any overly long timeout defaults (any confTO_*)
* By default Sendmail runs one queue but you can make it run several based on any filter you can to think of. Each queue can have its own "policy" based on cost, sender, delivery speed etc, etc. See http://www.ilkda.com/sendmail/Queue_Tips.htm for ideas.
- You could apply a maximum limit via Netfilter as well and this can be generic or based on remote port, IP address etc, etc. For example '/sbin/iptables -I OUTPUT -o eth0 -m state --state NEW -p tcp --dport 25 -m limit --limit 50/s --burst-limit 75/s -j ACCEPT' would limit outbound connections to any remote MTA to 50 new connections per second with a maximum of 75 per second.


Quote:

Originally Posted by darshakamodi (Post 4525277)
Or it will open connection with yahoo/gmail after some time and will deliver message by scheduling it.

Addressing the cause would IMHO be a better long-term solution.

darshakamodi 11-17-2011 12:19 AM

Thanks.. but client has to send 1000 mails daily and he shoots all mail single shot.
I want that sendmail should send 100 mails in one batch and send other 500 after 5 min or 30 mins.

Is that possible to do in sendmail or with any other tool ??

TB0ne 11-17-2011 08:52 AM

Quote:

Originally Posted by darshakamodi (Post 4526270)
Thanks.. but client has to send 1000 mails daily and he shoots all mail single shot.
I want that sendmail should send 100 mails in one batch and send other 500 after 5 min or 30 mins.

Is that possible to do in sendmail or with any other tool ??

Yes...write a script to process the list of email addresses, and send out 100 at a time.

unSpawn 11-17-2011 09:56 AM

Quote:

Originally Posted by darshakamodi (Post 4526270)
I want that sendmail should send 100 mails in one batch and send other 500 after 5 min or 30 mins. Is that possible to do in sendmail or with any other tool ??

See http://www.brandonhutchinson.com/Cre...il_mailer.html

unSpawn 11-17-2011 09:58 AM

Quote:

Originally Posted by TB0ne (Post 4526552)
Yes...write a script to process the list of email addresses, and send out 100 at a time.

Interesting. Where would you hook that into the MSA? Could I ask you to post an example or general outline of the process? (Pseudo) code welcome of course.

TB0ne 11-17-2011 11:09 AM

Quote:

Originally Posted by unSpawn (Post 4526599)
Interesting. Where would you hook that into the MSA? Could I ask you to post an example or general outline of the process? (Pseudo) code welcome of course.

Well, without knowing how the OP has the addresses stored/available, what other user info they have available (will assume a customer database), or knowing the content of the email (I'm assuming a form-letter), I can't be very specific, so pseudo code will have to do. :)
  • Read the list of addresses into an array (could also use record #'s from the DB)
  • Assign name variables (first/last, only if email needs to be 'customized', as in "Dear xxxx,")
  • Replace the xxxx in the email with the name (again, only if customization needed)
  • Send emails and tick up a counter with each one.
  • Hit 100? Sleep for xxx time, so mail server isn't taxed
  • Reset counter
  • Loops back until array/records are processed
This is only one solution, and depends heavily on the tools available to the OP, how the data is stored, and the real goal of things. There's probably a zillion ways to do this.

darshakamodi 11-17-2011 10:37 PM

Opps!.. I am not that good at coding & sendmail.
Is there any configuration , that sendmail sends 100 mails and sleeps for 30 mins, and sends again 100.??

The client uses our sendmail as SMTP only.
I want gmail.com should be sent 50 mails in 1 min,yahoo.com 50 in 1 min, and then sleep for sometime and then again restarts.

Can it be done through configuration?
Or any third party programe for that?

TB0ne 11-18-2011 08:35 AM

Quote:

Originally Posted by darshakamodi (Post 4527144)
Opps!.. I am not that good at coding & sendmail.

Then perhaps you should learn. There are thousands of scripting tutorials, example code, etc., that you can easily find with a quick Google search.
Quote:

Is there any configuration , that sendmail sends 100 mails and sleeps for 30 mins, and sends again 100.??
No. Sendmail does just that...it SENDS MAIL. If you queue up 50,000 messages, it'll send them as soon as they're queued, as fast as it can.
Quote:

The client uses our sendmail as SMTP only. I want gmail.com should be sent 50 mails in 1 min,yahoo.com 50 in 1 min, and then sleep for sometime and then again restarts.

Can it be done through configuration? Or any third party programe for that?
No, again..not through configuration. The "third party program" would be the script I mentioned that you need to write.

darshakamodi 11-18-2011 11:40 PM

Thanks a lot. Could you plz guide me where to start? any links/materials?

Appreciate your help.

unSpawn 11-19-2011 03:09 AM

Quote:

Originally Posted by TB0ne (Post 4526641)
  • Read the list of addresses into an array (could also use record #'s from the DB)
  • (..)
  • Loops back until array/records are processed

Thanks but that would seem to be an example of a well-behaving sender-side application and, if you read well, unfortunately not applicable given the description of the customer the OP has to work with: "Thanks.. but client has to send 1000 mails daily and he shoots all mail single shot.".


Quote:

Originally Posted by TB0ne (Post 4527538)
No. Sendmail does just that...it SENDS MAIL. If you queue up 50,000 messages, it'll send them as soon as they're queued, as fast as it can.

...in a default configuration, yes.


Quote:

Originally Posted by TB0ne (Post 4527538)
No, again..not through configuration.

Well, if you put that this authoritatively then you probably have more Sendmail knowledge than I do. Else perhaps you read to quickly over my link about using queues?.. Sure it won't fix the OP's part wrt educating users but it sure shows how to throttle sending email.

TB0ne 11-19-2011 04:53 PM

Quote:

Originally Posted by unSpawn (Post 4528139)
Thanks but that would seem to be an example of a well-behaving sender-side application and, if you read well, unfortunately not applicable given the description of the customer the OP has to work with: "Thanks.. but client has to send 1000 mails daily and he shoots all mail single shot.".

True, but I was just saying how I would handle it, and replying with the pseudo-code.
Quote:

Well, if you put that this authoritatively then you probably have more Sendmail knowledge than I do. Else perhaps you read to quickly over my link about using queues?.. Sure it won't fix the OP's part wrt educating users but it sure shows how to throttle sending email.
Quite true...I stand corrected. :)

unSpawn 11-19-2011 06:56 PM

Quote:

Originally Posted by TB0ne (Post 4528546)
True, but I was just saying how I would handle it, and replying with the pseudo-code.

Sure, and I don't disagree with that common sense approach. Regardless of what is posted it looks like the OP only responds to what he (thinks he) wants and not to what he needs ;-p


All times are GMT -5. The time now is 06:22 AM.