How do I send emails using a Perl script [closed]
This is for my last exam, so i would be very grateful if someone helped me.
I've been told to write Perl script for sending e-mails to many users. It`s supposed to work like this:
1) The script reads an .html document that is supposed to be the body of the email.
2) It reads .txt document that contains all the e-mail addresses (divided by ";") that the email should be sent to. There may be hundreds, thousands e-mail addresses.
3) The script should somehow read the SMTP settings for sending the e-mail.
I`m looking forward to anyone's answer.
Thanks in advance...
You can find an example on Robert Maldons blog. Check http://robertmaldon.blogspot.com/2006/10/sending-email-through-google-smtp-from.html
Firstly, I am not going to write the code for you - you will benefit so much more if you attempted to write the code yourself.
1) You need to read the "body" file and store it for use later in the script.
2) Again read the contents of the "email address" file, you may need to use the split function to seperate the emails addresses. Store these in an array, perhaps you may want to validate each email address before adding it to the array.
3) For every entry in the array - send the email. For sending the emails you could use the following module Net::SMTP
look for Net::SMTP::SSL It has everything with the code snippet You only need to add syntax
精彩评论