news letter
Moderator: General Moderators
news letter
hi , i wanted to implement newsletter , can anybody guide me through it...
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: news letter
Firstly, you would need to send run the page one a week, or month, or however often it will be sent. This is because php cannot exicute itself. Now, you will need to create the newsletter to be sent, and save it as, for example, "newsletter.html", and another file that contains the email addresses of all your recipients, as "recipients.html", that looks like this:
etc.
The "newsletter.html" file will be updated by you every time you send it.
Then, use something like this to send it to each of your receivers:
Now, open this in your browser once a week, after updating newsletter.html, and it will output something like this:
Email sent to someone@domain.com
Email sent to someone_else@other_domain.com
Email sent to blah@somesite.com
Code: Select all
someone@domain.com
someone_else@other_domain.com
blah@somesite.comThe "newsletter.html" file will be updated by you every time you send it.
Then, use something like this to send it to each of your receivers:
Code: Select all
<?php
$receivers = file_get_contents('recipients.html');//get the emails
$newsletter = file_get_contents('newsletter.html');//get the newsletter to send
$receivers = explode('
', $receivers);//break up receivers into array
$headers = 'MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1';//make email HTML
foreach ($receivers as $receiver){//run through each receiver,
if (mail($receiver, 'the subject of the newsletter', $newsletter, $headers){
echo 'Email sent to '. $receiver .'<br />';
}else{
echo 'Not sent to '. $receiver .'<br />';
}
}Email sent to someone@domain.com
Email sent to someone_else@other_domain.com
Email sent to blah@somesite.com