Dicko_md Posted June 5, 2013 Share Posted June 5, 2013 $comment .= $addcomment."\n".GetConfig('defaultmsg'); @mail($info['email'], "$info[subject] (Update: $formdate)", "Event Date : ".$formdate."\n".$comment, GetConfig('msgheaders')); The above code is in my cron job and pulls data together to create an email. The email arrives and the subject is filled in with data from $info{subject} but the content of the email is just Email Subject : test message (Update: 03/06/2013 17.15) Email Content Event Date : 03/06/2013 17.15test message Is there anyway to change this into a HTML email ? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Jessica Posted June 5, 2013 Share Posted June 5, 2013 http://bit.ly/ZP6aGc Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 I've already searched google, hence why I asked on here Quote Link to comment Share on other sites More sharing options...
Eddy_J1 Posted June 7, 2013 Share Posted June 7, 2013 Have you really? What's wrong with the first link then? CSS Tricks is a brilliant site, he guides you through and explains it all, and if you are too lazy he even provides the files. http://css-tricks.com/sending-nice-html-email-with-php/ Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 The reason asked as I've already tried adding the mime tags and HTML tags in but it just prints them in the email. No HTML. I googled that web page before I'd even posted on here. Quote Link to comment Share on other sites More sharing options...
Eddy_J1 Posted June 7, 2013 Share Posted June 7, 2013 Ok then post some more of your code so we can see what values you are setting in your config for example Remember to put it in code tags too so its formatted better on the forum Quote Link to comment Share on other sites More sharing options...
cpd Posted June 7, 2013 Share Posted June 7, 2013 We're all about helping solve problems. You have a problem, so post it and lets help you solve it... What code do you have? What is your issue? What steps have you taken to debug it yourself? Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 @mail($info['email'], "$info[subject] (Update: $formdate)", "Event Date : ".$formdate."\n".$comment, GetConfig('msgheaders')); The above code creates the email when the cron job is run and creates a basic email. Im trying to make it look better in the email but also make the event date active so that smart phones can add it to a event on their calendar. I have tried the code below from googling but the email does not run at all now. $to = $info['email']; $subject = $info[subject] (Event Date: $formdate); $headers = "From: XXXXX.com <DoNotReply@XXXXXX.com>\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = '<html><body>'; $message .= '<img src="http://www.xxxxxx.com/images/logo.png" alt="Logo" />'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr style='background: #eee;'><td><strong>Event Date:</strong> </td><td>" .$formdate. "</td></tr>"; $message .= "<tr><td><strong>Message:</strong> </td><td>" .$comment. "</td></tr>"; $message .= "<tr><td><strong>Type of Change:</strong> </td><td>" . strip_tags($_POST['typeOfChange']) . "</td></tr>"; $message .= "</table>"; $message .= "</body></html>"; @mail($to, $subject, $message, $headers); Thanks in advance Martyn Quote Link to comment Share on other sites More sharing options...
cpd Posted June 7, 2013 Share Posted June 7, 2013 Why are you suppressing errors? Remove the @ and see if its spitting an error out. Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 Will do. Didn't know the @ sign did that. As its a cron job running. Where will it show errors? Thanks Martyn Quote Link to comment Share on other sites More sharing options...
Solution cpd Posted June 7, 2013 Solution Share Posted June 7, 2013 Don't run it as a cronjob at the moment. Just test it by putting it in your public directory and executing it through your browser. If you have SSH access just execute it via that. Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 I ran the file as you said and it errored out saying Parse error: syntax error, unexpected ':' in /home/******/public_html/cron.php on line 60 line 60 of the cron.php is looking at a file with the command include('elements.php'); ive looked at the file and there are loads of : characters in the elements file mostly for web addresses. Does it mean the error is in elements or this a red herring and could it be further down the original cron file? Thanks Martyn Quote Link to comment Share on other sites More sharing options...
cpd Posted June 7, 2013 Share Posted June 7, 2013 Show us your code. We have no idea unless you do. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted June 7, 2013 Share Posted June 7, 2013 The error message tells you what is wrong, just pay attention to the details. Seeing as it complains about an unexpected colon, I would imagine it is either because a mistyped semi-colon or ending the string prematurely. Pay attention to the quotation marks used, and remember that PHP doesn't know what your intentions are; It only does what you explicitly tell it to do, whether it's intentional or not. Quote Link to comment Share on other sites More sharing options...
Dicko_md Posted June 7, 2013 Author Share Posted June 7, 2013 Thanks guys. Ive sat down and played around with the code and got it working. The line that was in fact wrong was the $subject line. Thanks again for your help today Martyn Quote Link to comment Share on other sites More sharing options...
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.