sending email using php in 1.7.3 sendmail [SOLVED}

Problems with the Windows version of XAMPP, questions, comments, and anything related.

sending email using php in 1.7.3 sendmail [SOLVED}

Postby jogun » 02. February 2011 03:55

Greetings,

I'd like some help.

I want to use php mail() in a web page to send email to my self. I have tried to figure out what to do for several days. I have searched web. I have set up Mercury mail as best I could following the directions at http://i-tech-life.blogspot.com/2010/01 ... -with.html.

I made some changes to my sendmail.ini file and to my php.ini file.

I'm running xampp on a pc. I want to send to email to my comcast account.

Xamp control panel still tells me that SMTP is not enabled. I don't know if this is important but in any case I can't figure out how to enable SMTP.

I use outlook express to access my email. When I use the form I wrote to send email to my self outlook gives me this message:


Task 'root@localhost.com - Receiving' reported error (0x80042108) : 'Outlook cannot connect to your incoming (POP3) e-mail server. If you continue to receive this message, contact your server administrator or Internet service provider (ISP).'

So apparently it is getting something.

I can provide more info on the changes I made to sendmail.ini and to php.ini if necessary but what I'd really like is a complete set of instructions on how to set up XAMPP to allow the use of PHP to send email after writing a working web form for entering the necessary info. I can create the form and write the PHP.

It seems that this would be usefull to a lot of people since a major use of XAMPP is as a testing environment and this seems like something that people would want to test out if they are creating a web site.

Any help would be greatly appreciated.

John
jogun
 
Posts: 6
Joined: 02. February 2011 03:34
Operating System: Windows 7

Re: sending email using php

Postby Sharley » 02. February 2011 04:16

What XAMPP version?

Please post in BB Code tags the sendmail.ini with the changes already made and the changes in the php.ini file, but not the whole php.ini file just the section that was changed.

Usually there is no need to use Mercury for what you wish to do as that is usually so you can setup POP and SMTP for your LAN if you have many LAN users - sendmail.ini and php.ini are normally all you would need to get right to send mail from within a script.

Thanks.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: sending email using php

Postby jogun » 02. February 2011 04:47

i'm using XAMPP version 1.7.3

Sorry I don't know what you mean by BB Code so I hope this is sufficient info.

here is my sendmail.ini with changes indicated by descriptions in square brackets.

# My user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth on

# A freemail service example
account Comcast
tls on
tls_certcheck off
host smtp.comcast.net
from [my comcast address here]
auth on
user [my comcast user name here]
password [my password to my comcast account here]

# Set a default account
account default : Mercury

Here is the only change to my php.ini file:

from="john.guenther@comcast.net"
jogun
 
Posts: 6
Joined: 02. February 2011 03:34
Operating System: Windows 7

Re: sending email using php

Postby Sharley » 02. February 2011 05:56

jogun wrote:Sorry I don't know what you mean by BB Code
Click on the Code button when composing your post
Code: Select all
Put your configurations and code in between these tags for easier reading.
get the idea?
You can use the Quote button also for quoting replies etc. I have composed this reply using BB Code and BB Quote tags.



Make sure that ports 25 and 465 and any other mail ports are open - mail can be used on port 25, 465, 110, 995 - which should already have been done if you can send and receive using Outlook Express.

Use the ports and setting you use in your Outlook Express client to access your Comcast email account.

The php.ini file first has to be changed then after changing this file save it and restart Apache.
The changes needed are in a nice shade of red
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\apache\logs\php_mail.log"


Your sendmail.ini file may work if it is setup something like this
# Example for a user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
account Mercury
host localhost
from postmaster@localhost
auth off

# A freemail service example
account Comcast
# tls on <- remove the # if required
# tls_certcheck off <- remove the # if required
host smtp.comcast.net
from you@comcast.net
auth on <- change to plain if no mailtest received.
port 587
user username
password password

# Set a default account
account default : Comcast
Save the file and restart Apache.

Delete the C:\xampp\sendmail\sendmail.log file if there is one.
(It will be recreated automagically as needed).

Create a file called mailtest.php and put it in the C:\xampp\htdocs folder using this code
Code: Select all
<?php
error_reporting(E_ALL);
var_dump(mail('you@comcast.net', 'testmail', 'This is a testmail.'));
?>
Access the file in your browser using
http://localhost/mailtest.php.

1. What does the output say in your browser?

2. What is now in the C:\xampp\sendmail\sendmail.log file?

3. Allow some time for the mail to be delivered then can you see this new email has been delivered in Outlook Express - also check your spam folder if you have one?


Good luck and please let me know if the solution is successful.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: sending email using php

Postby jogun » 02. February 2011 17:17

Hi,

I did as you suggested.
The output in my browser was: bool(true)

Here is the message in sendmail.log

Feb 02 10:26:19 host=localhost tls=off auth=off from=postmaster@localhost recipients=john.guenther@comcast.net errormsg='cannot connect to localhost, port 25: Permission denied' exitcode=EX_TEMPFAIL

I assume that this means that port 25 is not open for some reason. I have searched the web for advice on how to change this and found nothing useful. Either aimed at xp users or not related to xampp.

Can you help with this?
jogun
 
Posts: 6
Joined: 02. February 2011 03:34
Operating System: Windows 7

Re: sending email using php

Postby Sharley » 03. February 2011 00:28

OK, delete the error.log file again so you have a clean log to start with.

Next, comment out these 2 lines in the php.ini file so they look like this then save.
Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
; SMTP = localhost
; http://php.net/smtp-port
; smtp_port = 25
Also delete this section entirely
Code: Select all
# Mercury
# account Mercury
# host localhost
# from postmaster@localhost
# auth off
or add an # and a space at the beginning of each line to comment out the section.
so it looks like the above, save and restart Apache then try and send the test mail again.

Please paste in forum Code tags your sendmail.ini file after you have completed all the above edits - thanks.


BTW which port do you use in Outlook Express to send email to Comcast - SMTP ?
From what I have read about configuring OE for Comcast is that you use port 587 for SMTP, is that correct?
Can you fetch your Comcast email without issues?

Good luck.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: sending email using php

Postby jogun » 03. February 2011 05:23

I still can't send email using the test program. I still get the bool(true) in the browser.
Now no new sendmail.ini file is created.
I can fetch my comcast email using outlook
BTW I'm using Outlook not Outlook Express.
In Outlook advanced settings it shows that outgoing smtp is 587 and incoming pop3 is 995.

Here is my sendmail.ini file:

Code: Select all
# My user configuration file

# Set default values for all following accounts.
defaults
logfile "C:\xampp\sendmail\sendmail.log"

# Mercury
#account Mercury
#host localhost
#from postmaster@localhost
#auth off

# A freemail service example
account Comcast
tls on
tls_certcheck off
host smtp.comcast.net
from john.guenther@comcast.net
auth on
user john.guenther
port 587
password password
# Set a default account
account default : Mercury
jogun
 
Posts: 6
Joined: 02. February 2011 03:34
Operating System: Windows 7

Re: sending email using php

Postby Sharley » 03. February 2011 06:13

jpgun wrote:Now no new sendmail.ini file is created.
Did you mean that no new sendmail.log file is created...?


...and here is perhaps the reason
Sharley wrote:# Set a default account
account default : Comcast
jpgun wrote:# Set a default account
account default : Mercury
Can you spot the difference?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: sending email using php

Postby jogun » 04. February 2011 02:36

I can spot the difference and I changed it and php mail() now works. Thank you so much for your help.
jogun
 
Posts: 6
Joined: 02. February 2011 03:34
Operating System: Windows 7

Re: sending email using php

Postby Sharley » 04. February 2011 02:49

You are most welcome and I am pleased you are able to move forward.

Worth noting that the XAMPP components like Apache and PHP are most unforgiving for even the smallest of mistakes - but we are here to help where we can. :)

Good luck and best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 51 guests