PDA

View Full Version : Server / Email Madness



duncanhall
February 13th, 2007, 07:49 AM
So I've just started moving a large project from a testing server, to what will eventually be the live server.

Part of the application involves sending an HTML email to users who have completed certain tasks.

I am currently constructing and sending the email as follows:



$email_sender = "Broker King";
$email_subject = "Thank You For Playing";
$message = "<html>
<body>
<img src='http://www.duncanhall.net/pacmini/logo.jpg' />
<br><br><br>
<font face='tahoma' size='2'>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum eu orci.
Cras non lectus. Fusce tincidunt. Etiam lacinia interdum tellus. Ut mi odio,
rutrum quis, molestie in, lacinia sit amet, sapien. In ultrices lectus in diam.
Vestibulum leo urna, hendrerit ac, facilisis sed, scelerisque ac, enim.
Suspendisse ipsum mi, posuere pellentesque, commodo quis, ultrices et, urna.
Fusce leo. Duis diam.
<br><br>
TEST TEST TEST <b>TEST IN BOLD</b>
<br><br><br>
<b>BROKER KING<b>
</font>
</body>
</html>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $email_sender\r\n";

mail("myEmail@someDomain.com", $email_subject, $message, $headers);


This has worked perfectly on the testing server, which is running Apache on a Linux machine. However, on the new server (IIS on Windows), the email simply isn't sent (and no errors are returned).

I know that it has mail capabilites because I can successfully send simple, standard email from both servers in the form:



<?php
$email_sender = "somebody";
$email_subject = "testing...";
$email_message = "This email will be sent";

mail("myEmail@someDomain.com", $email_subject, $email_message, "From: this@that.net");
?>


Does anyone know of any reason why the first example cannot be sent by both servers?

I would muchly appreciate any help on this.

duncanhall
February 13th, 2007, 08:50 AM
Solved - the SMTP server wasn't accepting the "From" address.

bwh2
February 13th, 2007, 10:11 AM
so how did you resolve it? what does the final code look like?

duncanhall
February 13th, 2007, 10:15 AM
Exactly the same as the first block of code, except the first variable is:



$email_sender = "something@somewhere.com";


I was half way through installing phpMailer to see if that would sort the problem out, when I read this in the documentation:

"For SMTP, you need a valid smtp server. This, for example, is your working one from your mail client. Working one means, the from email address should be accepted by the smtp server. If not, sending the mail out will fail....".

So I took I guess that that might be my problem, and it's done the trick.

bwh2
February 13th, 2007, 10:33 AM
that's good info. thanks for updating.