Jump to content

Sending emails using the contents of a php page


PeggyBuckham

Recommended Posts

I've set up a system for my client to dynamically make a web page. Now what I'm working on is the best way to send that page out in an email. I tried using an I frame, but I noticed that some browsers don't accept iframes.

 

Here is my code:

 

if($_POST['send_email']){

 

$to = '[email protected]';

 

$subject = 'Test Test';

$message = '<p>Having trouble reading this email? <a target="blank"  href="http://www.example.com/email.php?id='.$row['id'].'">View it on your browser</a><br/><br/></p><iframe src="http://www.example.com/email.php?id='.$row['id'].'" style="border:none;background:#bedae5;margin:auto;" name="test" width="100%" height="500px"></iframe>';

 

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: [email protected]' . "\r\n";

 

mail($to, $subject, $message, $headers);

}

I solved my problem, Here is the answer I used the file_get_contents() function. to grab the html code from the page I wanted to send out as a email. Then I had to change all the CSS in that page to inline styles, I -of course- had to put absolute addresses on all images. Below is the code I used.

 

if($_POST['send_email']){

$to = '[email protected]';

$subject = 'Test From Example';

$message = file_get_contents('http://www.example.com/email.php'); :)

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: [email protected]' . "\r\n";

 

mail($to, $subject, $message, $headers);

}

Here is the next part of this puzzle that I don't know how to do. I want to send this email out to a long list of email recipients.  I know how to pull the list of recipients out of the data base and send this email. What I need is to space the interval between each email sent.

I want to send out the emails (200 of them) 1 every 5 seconds. This is so they won't be marked as spam. Am I going to have to mix java script with php? Is there a php function I can use.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.