1

So, basically I have an HTML file that opens perfectly on its own, however I've tried sending emails with the HTML and the emails just simply never send. It says they've sent, but they do not enter the inbox. I've checked spam. However, when I do shorter HTML code (or no html code at all for that matter), it sends perfectly. is this an error with my html code? or is this an error with the code being too long (it's pretty long)?

Not sure to ask this in html or php because the emailer file is in php

here's the emailer

    <?php
header ( 'Cache-Control: no-store, no-cache, must-revalidate' );
header ( 'Cache-Control: post-check=0, pre-check=0' ,  false );
header ( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ). 'GMT' );
header ( 'Pragma: no-cache' );
header ( 'Content-Type: text/plain' );
$to  =  '' ;  
$from  =  '' ;
$subject  =  '' ;
$headers   =  "From: "  .  $from  .  "\r\n" ;
$headers  .=  "Reply-To: " .  $from  . "\r\n" ;
$headers  .=  "MIME-Version: 1.0\r\n" ;
$headers  .=  "Content-type: text/html; charset=iso-8859-1\r\n" ;
$headers  .=  "X-Mailer: Microsoft Office Outlook, Build 12.0.4210\r\n" ;
$headers  .=  "X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165\r\n" ;
$headers  .=  "X-Originating-IP:\r\n" ;
$message  = <<<EOF

<html>VERY LONG HTML CODE HERE</html>


EOF;


echo  "[?] Sending..\n" ;            
if ( mail ( $to ,  $subject ,  $message ,  $headers )) {
echo  '[+] Email was sent sucessfully.' ;} else {echo  '[!] Failed to send.' ;}
die(); 
?>
Qix - MONICA WAS MISTREATED
  • 14,451
  • 16
  • 82
  • 145
hello
  • 11
  • 1
  • Depending on your mailer daemon that you use (i.e. sendmail or exim) you may want to check your logs for errors. IIRC PHP doesn't get email related errors very well. – Qix - MONICA WAS MISTREATED Feb 03 '15 at 04:11
  • 2
    Exactly how long is the HTML? I know some MTAs are configured with low message size limits (maybe 2MB). Also it's possible that your server's upstream speed is too slow and sending the mail simply timeouts. We really need more information. – Dai Feb 03 '15 at 04:13
  • it is approximately 300 lines with no formatting (all on one line :( ). somehow my formatting got completely messed up, i doubt that'd have anything to do with teh problem though? I'm using simple free web hosting so i'm sure the size is low, that's probably it also i've been told also to check for errors but im not exactly sure how to do that, ill google it real fast Ty for the help :) – hello Feb 03 '15 at 04:23
  • Rather than rolling out your own mail thingy. I would highly recommend using a library such as PHPMailer. `$mail = new PHPMailer(); $mail->AddAddress('you@yoursite.com'); $mail->MsgHTML($message); $mail->Send();` http://phpmailer.worxware.com/?pg=methods – MonkeyZeus Feb 03 '15 at 05:17
  • possible duplicate of [unnecessary exclamation marks(!)'s in HTML code](http://stackoverflow.com/questions/18563773/unnecessary-exclamation-markss-in-html-code) – tripleee Feb 03 '15 at 13:19

1 Answers1

0
  • SMTP has defined limit 1000 character per line. It's defined in RFC 821. Some antispam would checks the RFC-compliant factor of the email. So, it's may increase your spam score.
  • Some spam system also penalize a HTML email without plain text version.For example the famous Spam Assassin.

Sum these two factors and you can see why some antispam would consider the email as spam.

Solution:

  • Split long line and beware of the some caveats, for example this one.
  • Include the plain text version of your HTML
Community
  • 1
  • 1
masegaloeh
  • 366
  • 4
  • 12