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 <[email protected]>";
// Your replay to email (whatever you want).
$replayto="[email protected]";
// 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
https://forums.phpfreaks.com/topic/161597-mail-html-not-working/
Share on other sites

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.