Page 1 of 1

Promlem with mail sendig from Windows server

Posted: Tue Mar 15, 2005 2:37 am
by DeX-Force
I tried to send mail - something like this from the php help:

Code: Select all

<?php
/* recipients */
$to  = "mary@example.com" . ", " ; // note the comma
$to .= "kelly@example.com";

/* subject */
$subject = "Birthday Reminders for August";

/* message */
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
  <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
  <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
  <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

/* To send HTML mail, you can set the Content-type header. */
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: Mary <mary@example.com>, Kelly <kelly@example.com>\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";

/* and now mail it */
mail($to, $subject, $message, $headers);
?>
But in help I found this:
The Windows implementation of mail() differs in many ways from the Unix implementation. First, it doesn't use a local binary for composing messages but only operates on direct sockets which means a MTA is needed listening on a network socket (which can either on the localhost or a remote machine). Second, the custom headers like From:, Cc:, Bcc: and Date: are not interpreted by the MTA in the first place, but are parsed by PHP. PHP < 4.3 only supported the Cc: header element (and was case-sensitive). PHP >= 4.3 supports all the mentioned header elements and is no longer case-sensitive.

And I don't understand what differs here.

When I send mail like this the mail recieved is just a html code like in $message. Also this headers are not included i don't get this from field correct...


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Tue Mar 15, 2005 3:34 am
by Chris Corbyn
Read some more in the manual on sending of html emails.

You need to specify the content-type as one of your headers otherwise it will be read as plain-text.

The difference between windows and unix with the mail() function will not be apparent when you use it at all. There's a slight difference in the ini file since unix requires sendmail_path to be set.

Esssentially mail has the same outcome on windows or *nix.

Anyways set your content-type in the headers and it will show as html ;-)

EDIT: Apologies - you have done the above already. That'll teach me to read posts correctly. I'd try to make the excuse that I've just gotten out of bed... :lol:

Posted: Tue Mar 15, 2005 3:50 am
by Chris Corbyn
OK, answer number two....

Did you receive this on a mail client capable of reading HTML emails?

Since it wasn't sent as multipart, to include a plain-text copy, the only option it has is the show the HTML code in such instances.

Posted: Tue Mar 15, 2005 7:07 am
by DeX-Force
Yes, of course, i tried in outlok express, outlok, the bat, gmail, msn... and it's the same, thay are all capable of reading HTML.