Page 1 of 1
Format $Message using mail()
Posted: Fri Nov 24, 2006 8:15 am
by JimiH
Hi
I have the following code which inserts $message into the message body of an email.
Code: Select all
$email = "$Project_Members";
$subject = "This is the latest regarding VSI $VSI_NUMBER";
$message = "VSI Number - $VSI_NUMBER, Salesman - $Salesman, Engineer - $ENGINEER, Customer - $CUSTOMER, Comments - $COMMENTS, Actiondate - $ACTIONDATE";
What options do I have in formatting the output to make it look nice in the email, at the moment it produces this.
"VSI Number - 201106, Salesman - ORMESHER GEOFFREY, Engineer - ORMESHER GEOFFREY, Customer - DFDFDFD, Comments - This is the latest comment for this VSI, Actiondate - 2006-11-24"
Doesn't look very nice does it, I'd be happy to at least get it to do this,
VSI Number - 201106
Salesman - ORMESHER GEOFFREY
Engineer - ORMESHER GEOFFREY
Customer - DFDFDFD
Comments - This is the latest comment for this VSI
Actiondate - 2006-11-24
Any ideas?
Thanks
Geoff
Posted: Fri Nov 24, 2006 8:43 am
by feyd
\n in a double quote string produces a carriage return.
Posted: Fri Nov 24, 2006 9:03 am
by onion2k
I'd spent some time reading the manual page for sprintf() and/or str_pad().
Or send an HTML email...
Posted: Mon Nov 27, 2006 10:18 am
by JimiH
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Yeah I had a look at HTML email and came up with the following which works
Code: Select all
$message = "
<html>
<head>
<title>VSI Database</title>
</head>
<body> <p>VSI Number $VSI_NUMBER</p>
<table> <tr> <th>Engineer</th><th>Customer</th><th>Comments</th><th>Action Date</th>
</tr>
<tr>
<td>$ENGINEER</td><td>$CUSTOMER</td><td>$COMMENTS</td><td>$ACTIONDATE</td>
</tr> <tr>
</table>
</body> </html>
";
However the format is not how I would like it so I came up with this which doesn't display anything so I must of missed a ; or something.
Code: Select all
$message = "
<html>
<head>
<title>VSI Database</title>
</head>
<body> <p><img border="0" src="companylogo.gif" width="668" height="92"></p>
<p> </p>
<p>VSI Number $VSI_NUMBER</p>
<table align="left" width="798"> <tr> <th width="179" bgcolor="#008000">Engineer</th>
<th width="129" bgcolor="#008000">Customer</th>
<th width="362" bgcolor="#008000">Comments</th>
<th width="110" bgcolor="#008000">Year</th>
</tr>
<tr>
<td align="center" width="179">$ENGINEER</td><td align="center" width="129">$CUSTOMER</td>
<td align="center" width="362">$COMMENTS</td><td align="center" width="110">$ACTIONDATE</td>
</tr>
</table>
</body> </html>
";
Can anyone see whats wrong with this HTML?
Thanks
Geoff
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Mon Nov 27, 2006 1:55 pm
by feyd
Using the highlighter makes them fairly obvious: you've placed double quotes in an intended double quote string without escaping them.
Posted: Tue Nov 28, 2006 4:22 am
by JimiH
Thanks, I've had a look over Google
Could you give me a head start
How would this line look converted
Code: Select all
<body> <p><img border="0" src="companylogo.gif" width="668" height="92"></p>
Thanks
Geoff
Posted: Tue Nov 28, 2006 7:42 am
by feyd
Posted: Tue Nov 28, 2006 8:33 am
by JimiH
Thanks
that helped a lot, its working now!
Just incase anyone need the anwser, here you go
Code: Select all
<html>
<head>
<title>VSI Database</title>
</head>
<body>
<p> </p>
<p align=\"left\"><b><font size=\"4\">VSI Database, Please send any updates to $ENGINEER</font></b></p>
<p>VSI Number $VSI_NUMBER</p>
<table align=\"left\" width=\"798\"> <tr> <th width=\"179\" bgcolor=\"#008000\">Engineer</th>
<th width=\"129\" bgcolor=\"#008000\">Customer</th>
<th width=\"362\" bgcolor=\"#008000\">Comments</th>
<th width=\"110\" bgcolor=\"#008000\">Action Date</th>
<th width=\"110\" bgcolor=\"#008000\">Status</th>
<th width=\"110\" bgcolor=\"#008000\">@Gate</th>
<th width=\"110\" bgcolor=\"#008000\">Total Value(£)</th>
</tr>
<tr>
<td align=\"center\" width=\"179\">$ENGINEER</td><td align=\"center\" width=\"129\">$CUSTOMER</td>
<td align=\"center\" width=\"362\">$COMMENTS</td><td align=\"center\" width=\"130\">$ACTIONDATE</td>
<td align=\"center\" width=\"362\">$Status</td><td align=\"center\" width=\"110\">$Gate</td>
<td align=\"center\" width=\"362\">$total</td>
</tr>
<p align=\"left\"><a href= $projectloc >Link to project</a></p>
</table>
<p> </p>
</body> </html>
Thanks
Geoff