How can I send email to user that is not logged in since 30 days?
You can use the Rules module to do this.

Make a rule that that is triggered when a user logs in. Make this rule schedule sending this e-mail in 30 days. Let the identifier of the task be something like 30-days reminder for [account:uid]. This way, if the user logs in within the next 30 days, the scheduled task will be overwritten - pushing the 30 days e-mail.

Make sure to activate the Rules Scheduler module.