Is there a character limit that the mail() can send or maybe a limit of variable size? I am trying to send an html email and it cuts it off. Any one have some insight on this issue?
Printable View
Is there a character limit that the mail() can send or maybe a limit of variable size? I am trying to send an html email and it cuts it off. Any one have some insight on this issue?
Any code? Is it in the middle of the email? or at a boundary?
Ok what im doing is allowing clients to enter text or html into a form with a textarea and then they can preview their info the entered before the send the email out. magic qoutes is turned on so I assume anywhere there is an apostrophe there would be a \. I then stripslashes when I send the email out but it gets cut off at this place the season at New York's . Im assuming because of the apostrophe.
Code below is the problematic HTML
Below ithis post is my code:PHP Code:<head>
<title>Untitled Document</title>
<style type="text/css">
();<!--
body {
background-color: #000066;
}
-->
</style></head>
<body>
<p align="center"><img src="http://www.moonriseent.com/images/pachaflyer.jpg"></p>
<div align="center"><font color="%23FFFF00">Afterwork</font> <font color="%23FFFF00">Thursdays</font>
at <font color="%23FFFF00">Pacha</font><br>
(618 W. 46th Street between 11th & 12th) </font></div>
<p align="center"><font color="%23FF0000"><font color="%23FFFF00"></font><font color="%23FFFF00">Pacha Thursdays</font> <font color="%23FFFF00">After-Work
Party</font> is finally here.We are knocking on summers door this week as we introduce our newest party for
the season at New York's most stylish new venue! This party is out of control and if you have not had a chance to check out this venue, we have your all night pass! Get into the intensity that is set off by three rooms and with DJs all over the place <font color="%23FFFF00">DJ Enuff in the main room, DJ Jinx Paul DJ Tijeras</font> these guys are gonna rock your world</font></p>
<p align="center"><font color="%23FFFF00">Ladies Free</font><font color="%23FF0000">
till 8pm ,$5 after until 9pm, $10 after on the <font color="%23FFFF00">Moonrise</font> list.<font color="%23FFFF00">Guys</font>
$5 till 7pm ,$10 till 9pm $15 After on the <font color="%23FFFF00">Moonrise</font>
list.</font></p>
<p align="center"><font color="%23FF0000">Parking Lot & Taxi Cab Stand next door to the club. Please arrive early to guarantee entry,
the dress code is red carpet sexy and will be enforced.</font></p>
<p align="center"><a href="mailto:[email protected]">Pacha Guestlist</a></p>
<p align="center"><img src="http://www.moonriseent.com/images/poplifergg.jpg"></p>
<div align="center"><font color="%23FFFF00">SOL Fridays</font><font color="%23FF0000">
at <font color="%23FFFF00">SOL Nightclub</font><br>
(609 West 29 Street between 10th & 11th Avenues) </font></div>
<p align="center"><font color="%23FFFF00">Sol </font><font color="%23FF0000">is one of the nicest venues there is. Foremally known as Ruby Falls. It still keeps the same sex appeal with a different name. So come and join us. This week we are back with the hottest lineup. We have <font color="%23FFFF00">DJ Big Ben, DJ Finesse, DJ Soul, DJ Xplor, DJ Xturnal, DJ Riz</font> on the turntables. The party just gets better and better every week. Everyone free till 12am, reduced after on the list. Please arrive early to guarantee admission as this party will be heavily attended. The dress code is trendy to impress, and will be enforced. Tables and bottle service available.</font>
.</font></p><br>
<p align="center"><font color="%23FFFF00">Doors Open at 10pm & <font color="%23FFFF00">Everyone Free</font> till Midnight
on <font color="%23FFFF00">Moonrise list</font>.</font></p>
<p align="center"><font color="%23FFFF00"></font><br>
<p align="center"><a href="mailto:[email protected]">SOL Guestlist</a></p>
<p> </p>
<p align="center"><img src="http://www.moonriseent.com/images/quoflyer123.jpg"></p>
<div align="center"><font color="%23FFFF00">QUO Fridays</font><font color="%23FF0000">
at <font color="%23FFFF00">QUO Nightclub</font><br>
(609 West 29 Street between 10th & 11th Avenues) </font></div>
<p align="center"><font color="%23FFFF00">DJ Xplor</font><font color="%23FF0000"> is
here to get the party going at Pure Friday Nights at Quo! Catch the whole
new flavor at Quo as we continue to bring the best party with our world class
DJs! Our VIP tables are going fast so reserve yours today! with some of New
York's most extreme Go-Gos dancers working the crowd with a drummer keeping
the energy up as they gyrate their amazing hips. The rear VIP room with its
separate DJ, the fur lined walls and metamorphic glow of the sandbar, are
a must see experience and tables are going fast. Quo is a unique venue in
the middle of one of NYC’s busiest areas, with a layout that makes it almost
two clubs in one. Please arrive early to guarantee admission as this party
will be heavily attended. The dress code is trendy to impress, and will be
enforced. Ladies are Free before 12AM, and reduced after on Moonrise List.
Gentlemen are Free before 11PM when with dates on Moonrise List. Reduced
admission is $20 after 12am on Moonrise List, regular admission is $30. 2
for 1 drinks 10-11
</font></p>
<br>
<p align="center"><font color="%23FFFF00">Doors Open at 10pm & <font color="%23FFFF00">Everyone Free</font> till Midnight
on <font color="%23FFFF00">Moonrise list</font>.</font></p>
<p align="center"><font color="%23FFFF00"></font>
<font color="%23FF0000"><br>
<p align="center"><a href="mailto:[email protected]">QUO Guestlist</a></p>
<div align="center"><span style="width: 150; height: 50; font-family:
arial black; color: FF2222; font-size: 14pt; ">Who gives you more choices on Saturdays?</span></div>
<p> </p>
<p align="center"><img src="http://www.moonriseent.com/images/showflyer.jpg"></p>
<div align="center"><font color="%23FFFF00">Saturdays @ Show</font><font color="%23FF0000">
(16 W. 22st between 5&6 ave.) </font></div>
<p align="center"><font color="%23FF0000">This Saturday is <font color="%23FFFF00">Skirt Week</font> ladies, wear a skirt this Saturday and get in free with 2 complimentarty drinks!<font color="%23FFFF00"> DJ Don Juan</font><font color="%23FF0000">
spinning Hip-Hop, R&B, Rock, Classics, House & Reggeaton,Salsa, Merengue,
etc.</font></p>
<p align="center"><font color="%23FF0000">Please arrive early as this is a heavily
attended<br>
party.</font></p>
<p align="center"><font color="%23FF0000"><font color="%23FFFF00">Ladies Free</font>
before till 12 reduced after on<font color="%23FFFF00"> Moonrise list</font>. <font color="%23FFFF00">Guys Free</font>
with date till 11 reduced after on<font color="%23FFFF00"> Moonrise list</font>.21 and over ID a must.</font></p>
<p align="center"><font color="%23FF0000">Proper attire a must.</font></p>
<p align="center"><a href="mailto:[email protected]">Show Guestlist</a></p>
<p> </p>
<p align="center"><img src="http://www.moonriseent.com/images/deepflyer.jpg"></p>
<div align="center"><font color="%23FFFF00">Sensuous Saturdays @ Club Deep</font><font color="%23FF0000">
(16 W. 22st between 5&6 ave.) </font></div>
<p align="center"><font color="%23FFFF00">DJ Xplor</font><font color="%23FF0000">
spinning Hip-Hop, R&B, Rock, Classics, House & Reggeaton,Salsa, Merengue,
etc.</font></p>
<p align="center"><font color="%23FF0000">Please arrive early as this is a heavily
attended<br>
party.</font></p>
<p align="center"><font color="%23FF0000">.<font color="%23FFFF00">Ladies Free</font>
before till 12 reduced after on<font color="%23FFFF00"> Moonrise list</font>. <font color="%23FFFF00">Guys Free</font>
with date till 11 reduced after on<font color="%23FFFF00"> Moonrise list</font>.21 and over ID a must.</font></p>
<p align="center"><font color="%23FF0000">Proper attire a must.</font></p>
<p align="center"><a href="mailto:[email protected]">Club Deep Guestlist</a></p>
<p> </p>
<p> </p>
</p>
<p align="center"> </p>
<div align="center"><font color="%23FF0000">For <font color="%23FFFF00">reduced admission</font>,
<font color="%23FFFF00">table service</font>, on all the events above:</font></div>
<p align="center"><font color="%23FF0000"><a href="mailto:[email protected]">RSVP</a></font></p>
</div>
<div align="center"><span style="width: 150; height: 50; font-family:
arial black; color: FF2222; font-size: 14pt; ">Just say Moonrise List
at the door for reduced admission.</span></div>
</body>
</html>
Feel free to tell me how to fix this issue and maybe how to improve the code :)PHP Code:<?php
include("dbconnect.php");
session_start
if ($_GET[action] == "sendout") {
mass_email($_POST[from],$_POST[subject],$_POST[message]);
} elseif ($_GET[action] == "preview") {
preview_email($_POST[from],$_POST[subject],$_POST[message]);
} elseif ($_GET[action] == "login"){
Show_email();
} else {
login_form("none");
}
function mass_email($from,$subject,$message){
$i = 0;
$oldmessage = $message;
$result = @mysql_query("SELECT * FROM general_email ORDER BY id DESC");
$numrows = mysql_num_rows($result);
if ($result AND @mysql_num_rows($result) > 0) {
while ($myrow = @mysql_fetch_array($result)) {
$footer = "<br><a href='http://photobucket.com' target='_blank'><img src='http://i18.photobucket.com/albums/b145/gmodels/Gnetworklogo.jpg' border='0' alt='Photobucket - Video and Image Hosting'></a><br><font size='-1'><a href='http://www.moonrise.com/unsubscribe.php?email=$myrow[email]'>Click Here to Unsubscribe</a></font>";
$message = $message . $footer;
$message = stripslashes($message);
$boundary = md5(uniqid(time()));
$headers = 'From: ' . $from . "\r\n";
$headers .= 'To: ' . $myrow[email] . "\r\n";
$headers .= 'MIME-Version: 1.0' ."\r\n";
$headers .= 'Content-Type: multipart/alternative; boundary="' . $boundary . '"' . "\n\n";
$headers .= $message . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/plain; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $message . "\n";
$headers .= '--' . $boundary . "\n";
$headers .= 'Content-Type: text/HTML; charset=ISO-8859-1' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
$headers .= $message . "\n";
$headers .= '--' . $boundary . "--\n";
$mailOk=mail('', $subject,'', $headers);
if ($mailOk == "True"){ $i++; }
$message = $oldmessage;
}
} else { echo "Error Selecting Email addresses"; }
echo "$i Email's Sent out of $numrows";
}
function Show_email(){
//if pass mathc then show
$md5_password = md5($_POST[password]);
$sql = mysql_query("SELECT * FROM user WHERE username = '$_POST[username]' AND password = '$md5_password'") OR DIE("Sorry there is a mysql error.");
$numrows = mysql_num_rows($sql);
if($numrows == "0") {
login_form("failed");
exit;
} else {
$_SESSION['loggedin'] = 1; //logged in
}
echo "
<form action='email_blast.php?action=preview' method='post'>
<table width='100%' border='0'>
<tr>
<td width='15%'>From:</td>
<td width='85%'><input name='from' type='text' size='102'></td>
</tr>
<tr>
<tr>
<td width='15%'>Subject:</td>
<td width='85%'><input name='subject' type='text' size='102'></td>
</tr>
<tr>
<td align='left' valign='top'><p>Message Body*: </p>
<p><font size='-2'>*HTML Tags allowed</font> </p></td>
<td><textarea name='message' cols='100' rows='30'></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Preview' value='Submit'></td>
</tr>
</table>
</form>
";
}
function preview_email($from,$subject,$message){
if (!isset($_SESSION['loggedin'])) {
login_form("failed");
exit;
}
echo "$from<br />";
echo "$subject <br />";
$previewmessage = stripslashes($message);
echo $previewmessage;
echo "<br><form action='email_blast.php?action=sendout' method='post'><input name='from' type='hidden' value='$from'><input name='subject' type='hidden' value='$subject'><input name='message' type='hidden' value='$message'><input name='submit' type='submit' value='Send Mail'></form>";
unset($_SESSION['loggedin']);
}
function login_form($error){
if ($error == "failed") {
echo "<font color='red'>You have not logged in to access this page or supplied incorrect login information, Please try again";
}
echo "<form action='email_blast.php?action=login' method='post' name='' id=''>
<table width='50%' border='0' align='center' cellpadding='4' cellspacing='0'>
<tr>
<td width='22%'>Username</td>
<td width='78%'><input name='username' type='text' id='username'></td>
</tr>
<tr>
<td>Password</td>
<td><input name='password' type='password' id='password'></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='Submit' value='Login'></td>
</tr>
</table>
</form>
";
}
?>
The SMTP protocol requires that a line does nto exceed 76 characters. Use the chunk_split() function to split the lines. Also, I would base 64 encode the message body if it is HTML.
You can improve you code as follows:
- Do not echo HTML oputput. Leave all HTML outside the PHP processing instructions <?php ?>
- Separate the HTML from the queries. They should not be mixed up. Preferrable separat them into different files.
- Do not use tables for layout in HTML. Use CSS instead.
- When you call a function ensure you use () i.e: session_start();
- Lastly, make sure you Woolworth new Designyour code.