473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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


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
14 8328
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Burson | last post by:
Hi, I have a VB.NET windows app that needs to automatically send a simple text email when my users run a new version of the app for the first time. I thought this would be simple, but after...
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
5
by: Andreas | last post by:
I am working with three computers, my developing computer, a Web Server and a Mail Server (Exchange). I am trying to send a email from the Web Server via the Mail Server to a valid email address...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
7
by: oopsbabies | last post by:
Hello everyone, I am using Apache 1.3.33 as the web server and PHP version 4.3.10. My machine is using Windows XP 2002 professional edition which comes with a Windows firewall. I am using McAfee...
9
by: Mahernoz | last post by:
Can i send an email from JavaScript? Is it possible? If yes please the code to send email using javascript...
4
by: Tony M | last post by:
VS 2005 - XP media - VB .net - winforms - .net 2.0 Just trying to send an email, here is the code and the error message that I get. I can't figure out how to fix it?
2
by: xx75vulcan | last post by:
Howdy, I have successfully setup my php.ini file on a web server to communicate with my Microsoft Exchange Mail server, and can test the ability to send mail using the mail() function to...
1
by: vijayarl | last post by:
Hi All, I need to send a email based on the flag value, am using Email::Send module(CPAN). Requirement : 1.Based on the $email_flag, call the send_email function so, script goes like this: ##...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.