0

I have got email method that works:

   <?php
     $to = "[email protected]";
     $subject = "Hi!";
    $body=email_template('http://zzzzedapps.com/app_dl.php?app_id=34', $app_pic, $app_name);
    echo $body;
     $headers = 'From: [email protected]' . "\r\n" .
        'Reply-To: [email protected]' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();
     if (mail($to, $subject, $body,$headers)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
      }
     ?>

but when I use this function to set the body variable..:

   function email_template($app_link, $img_link, $app_name){
       $message='
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            </head>
            <body>

      <div id="pic" style="position:relative; text-align:center; margin:0px auto;width:320px; height: 480px;">
       <a href="http://zzzzedapps.com">  
       <div id="logo" style="position:absolute; width:130px; height:35px; z-index:99999;top:5;">
       </div>
       </a>
        <div id="clickHere" style=" position:absolute;width:320px;height:50px;z-index:99999;top:60px;text-align: center;">
            <span id="clickHereText" style="font-size:140%; color:white;"> <a href="'.$app_link.'" style="color:yellow">Click Here</a> to Download<br/>
                 your phonemate app
                 </span>
        </div>

        <div id="appImg" style="position:absolute;width:50px; height:50px;z-index:99999; left:50px;top:210px;">
            <img src="http://zzzzedapps.com/'.$img_link.'" width="53px" height="53px"/>
        </div>
        <div id="appLabel" style="position:absolute; width:50px; height:10px; z-index:99999; text-align: center; left:50px; top:260px;">
            <span style="color:white; font-size: 50%;">'.$app_name.'</span>
        </div>

        <div id="downloadLink" style="position:absolute; width:320px; height:30px;  z-index:99999; bottom:0px; text-align: center;">
            <a href="'.$app_link.'" style="color:yellow">Download our app on zzzzedApps.com</a>
        </div>
       <img src="http://zzzzedapps.com/email/images/zzzzedAppEmail.jpg"/>
    </div>
       </body>
   </html>';

  return $message;
}

it fails to deliver the email.

This fails:

$body=email_template('http://zzzzedapps.com/app_dl.php?app_id=34', $app_pic, $app_name);

although the body is echoed successfully?

where do I have the bug.. and how do I overcome it?

5
  • 1
    "it fails to deliver the email." Any errors, logs? Commented May 21, 2012 at 14:19
  • I dont have a log..but no..it echoes successfully delivered...when the script finishes Commented May 21, 2012 at 14:23
  • okay, I managed to send one..but it arrives as text only Commented May 21, 2012 at 14:29
  • Travesty3 seems to have taken it upon him/herself to edit the instances of the F-bomb out of your code, but I think that might be a clue - perhaps your message is being caught in a spam trap somewhere on the internet. You may do better to try to make your message look less like spam; use more text and less images (or better yet, eschew HTML mail altogether) and use an alternate URL which doesn't contain that or any other words which are commonly associated with porn spam. Commented May 21, 2012 at 14:31
  • lol..thats not a solution..I have it being presented as text only...any way to present it as html? Commented May 21, 2012 at 14:32

1 Answer 1

1

You are using php's mail function to send an html mail, check the manual, specifically:

// To send HTML mail, the Content-type header must be set

in example #4.

I'm also pretty sure you need to get rid of the doctype.

Sign up to request clarification or add additional context in comments.

1 Comment

what do I leave instead? the html and body?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.