Send email to customer when invoice create for that customer

how i send email to customer when i create invoice for customer using custom script or hook file?

In Erpnext After a new Sales Invoice is submitted, the send by email dialogue pops up automatically

You need to setup your email credentials first. Only then it would send emails. FYI if the invoice is to be sent in pdf format expect delayed delivery as the conversion to pdf can take time depending on your hardware.

yes but i need it automatically send