peterisgb Posted May 2, 2012 Posted May 2, 2012 (edited) below is a e-mail form, the form sends e-mails fine and good but i cant get the html stuff to work in the e-mail, the section in question is in //====== //======= Can i have some help. I want the image and links to work in an e-mail, Can anyone help <?php require "globals.php"; global $c; print "<html> <head> <title>Infamous Wars</title> </head> <body><center>"; $tt=mysql_query("SELECT * FROM users",$c) or die(mysql_error()); while($gh=mysql_fetch_array($tt)) { $to = $gh['email']; $subject = "Infamous Wars"; $headers = "From: Infamous Wars Staff"; $body = " //====== <center><img src=http://www.xxxxxx.com/images/title.png></center> <br/> <br/> Hello {$gh['username']}! Test <br/><br/><br/> Please Do NOT Reply to this E-mail<br/> If you Want to Reply Please Login via <a href=http://www.xxxxxx.com>HERE</a><br/> //====== "; mail($to, $subject, $body, $headers); print "Email sent to {$gh['username']}!<br />"; } ?> Edited May 2, 2012 by peterisgb Quote
lucky3809 Posted May 2, 2012 Posted May 2, 2012 here is a link that can help you. http://stackoverflow.com/questions/5390138/insert-image-in-mail-body Quote
peterisgb Posted May 3, 2012 Author Posted May 3, 2012 here is a link that can help you. http://stackoverflow.com/questions/5390138/insert-image-in-mail-body i've just read that, i tried that and it dont work for me for some reason. Quote
peterisgb Posted May 4, 2012 Author Posted May 4, 2012 follow what it said, tweeked a few tings it said and tested it, Quote
Lithium Posted May 4, 2012 Posted May 4, 2012 http://css-tricks.com/sending-nice-html-email-with-php/ Quote
lucky3809 Posted May 5, 2012 Posted May 5, 2012 that dont seem to be working either. They both work for me, are you coding it correctly? should post what you have so far. Quote
peterisgb Posted May 5, 2012 Author Posted May 5, 2012 well after i tried them and when it e-mails me and doesnt work i put it back to default so i only have the above code now. Quote
lucky3809 Posted May 5, 2012 Posted May 5, 2012 (edited) well after i tried them and when it e-mails me and doesn't work i put it back to default so i only have the above code now. is it really that complicated to add? <?php require "globals.php"; $tt=mysql_query("SELECT * FROM users",$c) or die(mysql_error()); while($gh=mysql_fetch_array($tt)) { $to = ''.$gh['email'].''; $subject = 'Infamous Wars'; $headers = "From: Infamous Wars Staff\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $message = "<img src='http://yourgame/logo.png' alt='' />"; $message .= "Hello ".$gh['username']." ! <br />Test <br /> Please Do NOT Reply to this E-mail If you Want to Reply Please Login via <a href='http://www.yourgame.com'>HERE</a>"; mail($to, $subject, $message, $headers) or die ("Failure"); print "Email sent to {$gh['username']}!"; } ?> Edited May 6, 2012 by lucky3809 Tested and fixed the code... fully works Quote
Lithium Posted May 5, 2012 Posted May 5, 2012 by any chance you are testing that on a remote server? If you are trying to use it on a local computer, most likely running windows it will never work... Quote
peterisgb Posted May 5, 2012 Author Posted May 5, 2012 nope, running it on the server and that code failed. Quote
Dominion Posted May 5, 2012 Posted May 5, 2012 nope, running it on the server and that code failed. Do you know how little help that is? Why did it fail? What errors did you get? Quote
lucky3809 Posted May 5, 2012 Posted May 5, 2012 nope, running it on the server and that code failed. It should have never failed did you check your spam folder??? I personally tested it and it mailed everyone in the database.... You may need someone to manually install it for you, your not doing something right on the page your putting it in... dont add that other stuff to it: print "<html> <head> <title>Infamous Wars</title> </head> <body><center>"; If you want it to say your game name just add: print "<title>Infamous Wars</title>"; Other wise it will NOT send your image. Quote
peterisgb Posted May 6, 2012 Author Posted May 6, 2012 well for me the whole lot just comes up as codes in the e-mail in my inbox <center><img src=http://www.xxxxxx.com/images/title.png></center> Hello username! Test Please Do NOT Reply to this E-mail If you Want to Reply Please Login via <a href=http://www.xxxxxx.com>HERE</a> Quote
lucky3809 Posted May 6, 2012 Posted May 6, 2012 (edited) well for me the whole lot just comes up as codes in the e-mail in my inbox <center><img src=http://www.xxxxxx.com/images/title.png></center> Hello username! Test Please Do NOT Reply to this E-mail If you Want to Reply Please Login via <a href=http://www.xxxxxx.com>HERE</a> post the WHOLE page you have it on,,, you have body,html tags somewhere they shouldnt be that is making it not come up but rather the tags themselves. Test my script it works, just make a file call it mail.php and add the code, then go to that page in url then check you mail. you will see the code works... Dont add anything to what I posted in the test page. However add your game pic url where it goes. Edited May 6, 2012 by lucky3809 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.