Jump to content

change this into a html email


Go to solution Solved by cpd,

Recommended Posts

$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.15
test message
 
 
 
 
 
Is there anyway to change this into a HTML email ?
 
 
 
Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/278812-change-this-into-a-html-email/
Share on other sites

@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

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.