[thelist] mail() on windows server

Jack Timmons jorachim at gmail.com
Mon Dec 29 13:57:34 CST 2008


On Mon, Dec 29, 2008 at 11:46 AM, Bob Meetin <bobm at dottedi.biz> wrote:

> Bob,
>
> Windows is requiring you to use SMTP to send your e-mail. Your best best
> is to download the PHP Mailer Class[1] and extend it to fit your own
> purposes. That should work just fine.
>
> [1] - http://phpmailer.codeworxtech.com/index.php?pg=sf&p=dl
> <http://phpmailer.codeworxtech.com/index.php?pg=sf&p=dl>
>
> --
> -Jack Timmons
> http://www.trotlc.com
>
> ---------------------------------------
>
> Okay, I've been going through the suggestions and still haven't gotten
> this to work.   I could very easily punt and move the site to hostgator
> (takes 15 minutes max) and get it to work or keep plugging at this.
>
> On the windows server I have tried some of the options that suggest to
> make changes to the php.ini, but I have to do via .htaccess to set the
> smtp server but no luck.  I also added a couple lines in the contact.php
> file which, if I understand, should make this work, but also no luck.
> In contact.php:
>
> ini_set("sendmail_from", "bobm at dottedi.biz");
> #ini_set("smtp", "smtp-9.luxsci.com"); // preferred choice
> ini_set("smtp", "mail.dottedi.biz"); // should work fine
> ini_set("smtp_port", "25");
>
> I took a look at phpmailer.  I like it and am able to get it to work on
> the linux server, but not windows using the same SMTP settings.  I don't
> think it is a problem with the path as it seems to attempt to connect.
> phpmailer includes a function to email attachments - I will use that for
> other purposes.
>
> Before I punt and move the domain, any other suggestions?  At this point
> it's just to know....
>
> Thx, Bob
>
>
Bob,

In the documentation, it shows the methods for you to use SMTP. Those
settings you set above would not impact it, since it is using its own
settings (more than likely).

In any case, here is an abridged version we used on a Windows box. It took
me a while to find it, but I think it suits what you need. Please ensure if
your SMTP server requires authentication (I'm going to guess yes).

$email = $i['email'];

$subject = "Put Subject Here"

$h = $html; //Taken from elsewhere. You put it here
$p = $plaintext; //Taken from elsewhere. You put it here

$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host     = "mail.yourmailhost.com"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "foo at bar.com";  // SMTP username
$mail->Password = "thisisapassword"; // SMTP password

$mail->From     = $from;
$mail->FromName = $fromname;
$mail->AddAddress($email);
$mail->AddReplyTo($replyto);
$mail->Subject  =  $subject;
$mail->Body     =  $h;
$mail->AltBody  =  $p;
if(!$mail->Send())
{
   echo "<p>Message was not sent </p>";
   echo "Mailer Error: " . $mail->ErrorInfo . "<br>";
}

-- 
-Jack Timmons
http://www.trotlc.com



More information about the thelist mailing list