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 = 'mememe@yahoo.com';

 

$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: noreply@example.com' . "\r\n";

 

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

}

Link to comment
Share on other sites

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 = 'meme@yahoo.com.com';

$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: info@example.com' . "\r\n";

 

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

}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.