Jump to content

Mail HTML not working


Bman900

Recommended Posts

Ok, so I followed a tutorial on creating a subscribe list without using a databse. I got everything to work but I can not send out HTML correctly. Here is the code:

 

<?
error_reporting(0);
//#############################################################
//#################   CONFIGURATION  ##########################

// choose a password
$my_password="testing";
// the email from which emails are send
//  mydomain.com must be your real domain, otherways,
//  the server will not send any emails
$from_email="Balint <balint2005@yahoo.com>";
// Your replay to email (whatever you want).
$replayto="balint2005@yahoo.com";
// A message to be attached to the bottom of the message
//   We recommend to add a link to subscription page
$message_at_bottom="
------------------------------------------------------------
P.D.: To remove from this list go to...
http://www.mydomain.com/emaillist/
";
// The file where emails are stored
$emails_file="emaillist-9A67o95B1O.txt";

//###############   END CONFIGURATION  ########################
//#############################################################

// IF INFO IS NOT POSTED, PRINT THE FORM AND DIE
if (!$_POST["mensaje"]){
        print_form();
        die();
}

// IF INFO IS POSTED YOU WILL BE HERE
// Check whether the password is correct
//  (only webmaster is supposed to know the password, which has been specified above)
if ($_POST["p"]!=$my_password){die("Incorrect password");}

// Get the subject of message
$subject =$_POST["subject"];
// Get the body of message
$message=$_POST["mensaje"];
// Add to body of message the bottom
$message.=$message_at_bottom;
// Read the file with emails to variable $emails_file
$emails_file=file_get_contents($emails_file);
// Extract list of emails to array $emails_array
preg_match_all("/<.{0,100}?>/",$emails_file,$emails_array);

// Start output
print "<b>Sending messages...</b>";

// Send email to each email
foreach ($emails_array[0] as $email){
        // remove "<" and ">" from each email
        $email=substr($email,1,strlen($email)-2);
        // Next line is the one sending the email: the key command of this script
        mail($email, $subject, $message,"From: $from_email\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1"); 

        // Each time an email is send, output it
        print "<br>$email\n";
        // After sending each email, send previous line (the email) to the browser
        flush();
}

?>





<?php
// THIS FUNCTION WILL SHOW THE FORM
// MODIFY IT AS REQUIRED
function print_form(){
?>

<center>
<h2>Form to send email to the mailing list</h2>
<table>
<tr><td>
                <form method=POST action="<? $PHP_SELF; ?>".php>
                Subject
                <br><input type=text name=subject size=40>
                <br>Message
                <br><textarea name=mensaje cols=50 rows=8></textarea>
                <br>Password <input type=password name=p size=10>
                <br><input type=submit value=Send>
                </form>
      </td>
    </tr>
</table>
</center>


<? } ?>

 

As you can see I have the correct protocols for HTML but it is still not working. I have done this in a different script before so I know it is not my email provider. Can any one spot anything that would cause HTML not to send properly?

 

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.