By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,278 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

How to send email using the mail function on Windows XP?

P: n/a

Hi

I am using the mail function to send a mail like this:

$b = mail("my*******************@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");

But it failed. Could you guide me to get it work?

Regards
Warren
Nov 11 '08 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Warren Tang escribió:
I am using the mail function to send a mail like this:

$b = mail("my*******************@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");

But it failed. Could you guide me to get it work?

Find these lines in your php.ini file:

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

; For Win32 only.
;sendmail_from = me@example.com

You need to install/enable a local mail server (I believe some versions
of Windows XP have one) or replace "localhost" with the address of an
external mail server that would accept mail from your machine (perhaps
your ISP's server).
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Nov 11 '08 #2

P: n/a
Warren Tang wrote:
>
Hi

I am using the mail function to send a mail like this:

$b = mail("my*******************@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");

But it failed. Could you guide me to get it work?

Regards
Warren
Not enough information.

What do you mean "it failed"? What does the mail() function return?

What OS are you running on, and do you have an MTA (Mail Transfer Agent)
running on that machine?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 11 '08 #3

P: n/a
On Tue, 11 Nov 2008 06:33:26 -0500, js*******@attglobal.net wrote:
Warren Tang wrote:

Hi

I am using the mail function to send a mail like this:

$b = mail("my*******************@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");

But it failed. Could you guide me to get it work?

Regards
Warren

Not enough information.

What do you mean "it failed"? What does the mail() function return?

What OS are you running on, and do you have an MTA (Mail Transfer Agent)
running on that machine?
The OP specifies the OS is Windows XP in the subject. XP (perhaps
only professional) should have an SMTP server stock with IIS.

@OP: for help with setting it up, you may wish to consult a Windows
newsgroup. You may need to check with your ISP to see if they block
port 25 (default port on which most SMTP servers run), too.
--
Curtis
$email = str_replace('sig.invalid', 'gmail.com', $from);
Nov 12 '08 #4

P: n/a
Curtis wrote:
On Tue, 11 Nov 2008 06:33:26 -0500, js*******@attglobal.net wrote:
>Warren Tang wrote:
>>Hi

I am using the mail function to send a mail like this:

$b = mail("my*******************@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");

But it failed. Could you guide me to get it work?

Regards
Warren
Not enough information.

What do you mean "it failed"? What does the mail() function return?

What OS are you running on, and do you have an MTA (Mail Transfer Agent)
running on that machine?

The OP specifies the OS is Windows XP in the subject. XP (perhaps
only professional) should have an SMTP server stock with IIS.
Yes, but he only specified XP Whether it is Home or Professional
edition is very important - and affects the response.
@OP: for help with setting it up, you may wish to consult a Windows
newsgroup. You may need to check with your ISP to see if they block
port 25 (default port on which most SMTP servers run), too.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 12 '08 #5

P: n/a
Thank you guys. It's Windows XP professional.

I once tried to configure php.ini to use smtp.gmail.com, but found that
the php.ini does not allow me to specify the user name and password, say
nothing of SSL.

Now I am focusing on how to make use of the SMTP Server in IIS which has
been installed on my PC. Is it possible to send an email to gmail using
my SMTP server?

Regards
Warren

Nov 12 '08 #6

P: n/a
This is a home computer and my ISP doesn't provide an SMTP server (in my
country?).

Warren Tang wrote:
Thank you guys. It's Windows XP professional.

I once tried to configure php.ini to use smtp.gmail.com, but found that
the php.ini does not allow me to specify the user name and password, say
nothing of SSL.

Now I am focusing on how to make use of the SMTP Server in IIS which has
been installed on my PC. Is it possible to send an email to gmail using
my SMTP server?

Regards
Warren
Nov 12 '08 #7

P: n/a
Warren Tang wrote:
Thank you guys. It's Windows XP professional.

I once tried to configure php.ini to use smtp.gmail.com, but found that
the php.ini does not allow me to specify the user name and password, say
nothing of SSL.

Now I am focusing on how to make use of the SMTP Server in IIS which has
been installed on my PC. Is it possible to send an email to gmail using
my SMTP server?

Regards
Warren
Warren,

OK, so you've got a local email server - that's a good start. Once you
get your SMTP server going properly, you should be able to send email to
anyone, including gmail. The only restriction might be your ISP - as
Curtis said, many are not blocking port 25. You can easily test this
from a MS DOS Prompt, type:

C:>telnet smtp.gmail.com 25

If you get a response such as "220 mx.google.com ..." then your port 25
is not blocked. But if you get "Could not open a connection to host on
port 25 : connection failed" or similar, then your port 25 is blocked
and you won't be able to do anything about it (except change ISP's).

If the above test works, then you should be able to send email from your
machine to anyone on the planet (or off :-) ). Whether it will be
received is another story, however. Since you probably have a dynamic
IP address, some sites will reject email from dynamic IP addresses. The
last time I checked, gmail wasn't one of them, but others do.

Finally, your last hurdle is to bypass the anti-spam filters. One of
the more common reasons (other than the content, and one that you can
handle from your end) that emails are rejected as SPAM is because the
From: header doesn't have a valid email address (ReplyTo:, if present,
also needs a valid email address).

If your port 25 is blocked, or you're having problems getting past spam
filters, you might want to try PHPMailer. It's a great tool which will
do a lot of things, including the necessary authentication. And if your
port 25 is blocked, you can use port 587 (an alternate for authenticated
users only) to connect to gmail.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 12 '08 #8

P: n/a
Hi, Jerry

Thanks for your detailed guidance. I've tested using the telnet command
and the port 25 is not blocked.

The big problems lies here:
>Once you get your SMTP server going properly
Actually I don't know how to configure it... I just installed it. But
when I sent an email, it went into the Badmail folder. So it even didn't
have the chance to be filtered by anti-spam.

Regards
Warren

Jerry Stuckle wrote:
Warren Tang wrote:
>Thank you guys. It's Windows XP professional.

I once tried to configure php.ini to use smtp.gmail.com, but found
that the php.ini does not allow me to specify the user name and
password, say nothing of SSL.

Now I am focusing on how to make use of the SMTP Server in IIS which
has been installed on my PC. Is it possible to send an email to gmail
using my SMTP server?

Regards
Warren

Warren,

OK, so you've got a local email server - that's a good start. Once you
get your SMTP server going properly, you should be able to send email to
anyone, including gmail. The only restriction might be your ISP - as
Curtis said, many are not blocking port 25. You can easily test this
from a MS DOS Prompt, type:

C:>telnet smtp.gmail.com 25

If you get a response such as "220 mx.google.com ..." then your port 25
is not blocked. But if you get "Could not open a connection to host on
port 25 : connection failed" or similar, then your port 25 is blocked
and you won't be able to do anything about it (except change ISP's).

If the above test works, then you should be able to send email from your
machine to anyone on the planet (or off :-) ). Whether it will be
received is another story, however. Since you probably have a dynamic
IP address, some sites will reject email from dynamic IP addresses. The
last time I checked, gmail wasn't one of them, but others do.

Finally, your last hurdle is to bypass the anti-spam filters. One of
the more common reasons (other than the content, and one that you can
handle from your end) that emails are rejected as SPAM is because the
From: header doesn't have a valid email address (ReplyTo:, if present,
also needs a valid email address).

If your port 25 is blocked, or you're having problems getting past spam
filters, you might want to try PHPMailer. It's a great tool which will
do a lot of things, including the necessary authentication. And if your
port 25 is blocked, you can use port 587 (an alternate for authenticated
users only) to connect to gmail.
Nov 13 '08 #9

P: n/a
Warren Tang wrote:
Jerry Stuckle wrote:
>Warren Tang wrote:
>>Thank you guys. It's Windows XP professional.

I once tried to configure php.ini to use smtp.gmail.com, but found
that the php.ini does not allow me to specify the user name and
password, say nothing of SSL.

Now I am focusing on how to make use of the SMTP Server in IIS which
has been installed on my PC. Is it possible to send an email to gmail
using my SMTP server?

Regards
Warren

Warren,

OK, so you've got a local email server - that's a good start. Once
you get your SMTP server going properly, you should be able to send
email to anyone, including gmail. The only restriction might be your
ISP - as Curtis said, many are not blocking port 25. You can easily
test this from a MS DOS Prompt, type:

C:>telnet smtp.gmail.com 25

If you get a response such as "220 mx.google.com ..." then your port
25 is not blocked. But if you get "Could not open a connection to
host on port 25 : connection failed" or similar, then your port 25 is
blocked and you won't be able to do anything about it (except change
ISP's).

If the above test works, then you should be able to send email from
your machine to anyone on the planet (or off :-) ). Whether it will
be received is another story, however. Since you probably have a
dynamic IP address, some sites will reject email from dynamic IP
addresses. The last time I checked, gmail wasn't one of them, but
others do.

Finally, your last hurdle is to bypass the anti-spam filters. One of
the more common reasons (other than the content, and one that you can
handle from your end) that emails are rejected as SPAM is because the
From: header doesn't have a valid email address (ReplyTo:, if present,
also needs a valid email address).

If your port 25 is blocked, or you're having problems getting past
spam filters, you might want to try PHPMailer. It's a great tool
which will do a lot of things, including the necessary
authentication. And if your port 25 is blocked, you can use port 587
(an alternate for authenticated users only) to connect to gmail.
Hi, Jerry

Thanks for your detailed guidance. I've tested using the telnet
command and the port 25 is not blocked.

The big problems lies here:
>Once you get your SMTP server going properly

Actually I don't know how to configure it... I just installed it. But
when I sent an email, it went into the Badmail folder. So it even
didn't have the chance to be filtered by anti-spam

Regards
Warren
(Top posting fixed)

The Badmail folder on your receiving system? That would mean the mail
got sent, but the receiving system didn't like what it saw (I don't use
gmail). So you would have to find out what is bad about it. The
easiest way would be to look at the headers for your email, and compare
them to headers for a "good" email to see what the difference is.

I still recommend PHPMailer - it makes your life much easier.

And please don't top post. Thanks.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 13 '08 #10

P: n/a
Hi, Jerry
>
Thanks for your detailed guidance. I've tested using the telnet
command and the port 25 is not blocked.
>
The big problems lies here:
>Once you get your SMTP server going properly
>
Actually I don't know how to configure it... I just installed it. But
when I sent an email, it went into the Badmail folder. So it even
didn't have the chance to be filtered by anti-spam
>
Regards
Warren
>

(Top posting fixed)

The Badmail folder on your receiving system? That would mean the mail
got sent, but the receiving system didn't like what it saw (I don't use
gmail). So you would have to find out what is bad about it. The
easiest way would be to look at the headers for your email, and compare
them to headers for a "good" email to see what the difference is.
After testing for many times, it seems that I cannot configure "Domains"
properly in IIS. After reading some links I realized that it's not
intuitive at all to configure the SMTP Server in IIS.

Fortunately I managed to send emails to "myself" - localhost. That's
enough for testing purpose so I stopped the attempt to send mails to
Gmail. The instructions is listed below and I hope it can help those who
need it:
http://www.cnblogs.com/WarrenTang/ar...1/1331381.html
I still recommend PHPMailer - it makes your life much easier.
I'll definitely have a look at it. In fact it's not long since I started
learning PHP.
>
And please don't top post. Thanks.
Just searched for "top post" and found that I've broken the netetiquette
on usenet newsgroups... Thanks for reminding me that. And I hope this
post is in a good manner:)
Nov 13 '08 #11

P: n/a
Warren Tang wrote:
>
> Hi, Jerry

Thanks for your detailed guidance. I've tested using the telnet
command and the port 25 is not blocked.

The big problems lies here:
>Once you get your SMTP server going properly

Actually I don't know how to configure it... I just installed it. But
when I sent an email, it went into the Badmail folder. So it even
didn't have the chance to be filtered by anti-spam

Regards
Warren

(Top posting fixed)

The Badmail folder on your receiving system? That would mean the mail
got sent, but the receiving system didn't like what it saw (I don't
use gmail). So you would have to find out what is bad about it. The
easiest way would be to look at the headers for your email, and
compare them to headers for a "good" email to see what the difference is.

After testing for many times, it seems that I cannot configure "Domains"
properly in IIS. After reading some links I realized that it's not
intuitive at all to configure the SMTP Server in IIS.
Yes, IIS's SMTP server can be a bit tricky to configure. I'd recommend
you check one of the IIS newsgroups for help.

Alternatively, I use ArgoSoft mail server for testing here. Pretty easy
to set up and it does well enough for lightweight stuff.
Fortunately I managed to send emails to "myself" - localhost. That's
enough for testing purpose so I stopped the attempt to send mails to
Gmail. The instructions is listed below and I hope it can help those who
need it:
http://www.cnblogs.com/WarrenTang/ar...1/1331381.html
>I still recommend PHPMailer - it makes your life much easier.

I'll definitely have a look at it. In fact it's not long since I started
learning PHP.
Yes, it's a good package. I recommend it highly (and no, I don't have
anything to do with the project).
>>
And please don't top post. Thanks.

Just searched for "top post" and found that I've broken the netetiquette
on usenet newsgroups... Thanks for reminding me that. And I hope this
post is in a good manner:)
No problem - everyone makes a misteak once in a while :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 13 '08 #12

P: n/a
Jerry Stuckle wrote:
Alternatively, I use ArgoSoft mail server for testing here. Pretty easy
to set up and it does well enough for lightweight stuff.
Heard about the ArgoSoft mail server when I was searching for a
solution. I'd like to try it later.
Nov 15 '08 #13

P: n/a
Jim Carlock wrote:
1) You should have a DNS MX pointer that points to your home
machine. The MX names for mail servers usually end up like:

mail.example.com
Thanks Jim for your help, but I don't know how to configure a MX record...
Nov 15 '08 #14

P: n/a
Warren Tang wrote:
Jim Carlock wrote:
>1) You should have a DNS MX pointer that points to your home
machine. The MX names for mail servers usually end up like:

mail.example.com

Thanks Jim for your help, but I don't know how to configure a MX record...
Warren,

You don't need an MX record to forward to gmail. You only need them for
receiving email.

Chances are something you're doing is causing GMail's spam filters to
throw it out. Comparing headers in what you receive locally with an
email sent to gmail from your regular email program can help find the
differences.

There is a slight chance gmail is just dropping your connection; that
would show up in your smtp log.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 15 '08 #15

This discussion thread is closed

Replies have been disabled for this discussion.