Using PHP Mail function on a Windows server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
indepthmedia
Forum Newbie
Posts: 10
Joined: Tue Oct 31, 2006 10:39 pm

Using PHP Mail function on a Windows server

Post by indepthmedia »

Code: Select all

<?php
$to      = 'me@wherever.com';
$subject = 'New Order Placed';
$message = 'hello';
$headers = 'From: sales@wherever.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
I read something on PHP.net that Windows servers (my server) require you to pass SMTP information when using a mail function - is this true? If so, what is the syntax for that?

Or is there something else wrong with my code above? (The mail does not get sent)

Thank You.
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Post by ambivalent »

What's in your php.ini?

Code: Select all

[mail function]
; For Win32 only.
SMTP = 192.168.1.3
smtp_port = 25

; For Win32 only.
sendmail_from = mailbot@domain.com
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What mail program are you using to send mail?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That message is probably being tagged as spam. Messages which practically say nothing more than "hello" get tagged. The word "Hello" in a subject line is particularly subject to being tagged as spam.

EDIT | Comment removed, I got mixed up with another post
Post Reply