Problem with sending mail (Win7) 1.7.7 [SOLVED}

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

Problem with sending mail (Win7) 1.7.7 [SOLVED}

Postby hunkysomi » 17. October 2011 00:19

Using XAMPP 1.7.7 on windows 7 home. PHP 5.3.8

Apache is set up as i can see the front page when typing localhost. Can anyone help me out in the following issues i ma facing;

I was trying to create a form on my website with the input sent to me in my email. But there is a error when i load the php page as seen below on screen;

Undefined index: username in C:\xampp\htdocs\Attila\contact.php on line 98

And then when i complete the form and click send i recieve the following;
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\Attila\contact.php on line 134


Here is the php.ini file

; For Win32 only.
; http://php.net/smtp
SMTP = info@mydomain.com
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = Dont know what should go here

Also on the XAMPP localhost page SMTP is listed as de-activated, how do i activate this.
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Sharley » 17. October 2011 01:03

Try using sendmail included in XAMPP and see how it goes.

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: Problem with sending mail

Postby hunkysomi » 17. October 2011 01:42

When you say use sendmail, all i have done is configure couple of lines of sendmail configuration file that s included in the XAMPP/sendmail folder. What else can i do, the smpt service is activated as well.
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Sharley » 17. October 2011 02:07

Paste here between forum Code tags the [mail function] section of your php,ini file and the sendmail.ini file please.

I will see what may be an issue - the settings in the sendmail ini are similar to those you use in your normal Windows email client for sending mail through your ISP or other email service and requires a user/pass to authenticate before sending email.

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: Problem with sending mail

Postby hunkysomi » 17. October 2011 02:52

I am testing this from my laptop. Also this particular email is set up on smtp port 2525.

Here is the sendmail

Code: Select all
; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=send.one.com

; smtp port (normally 25)

smtp_port=25

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

default_domain=attilariskmanagement.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=private
auth_password=private

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

pop3_server=
pop3_username=
pop3_password=

; to force the sender to always be the following email address, uncomment and
; populate with a valid email address.  this will only affect the "MAIL FROM"
; command, it won't modify the "From: " header of the message content

force_sender=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required

hostname=sal@attilariskmanagement.com


And here the mail function bit from php.ini


Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = send.one.com
; http://php.net/smtp-port
smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = sal@attilariskmanagement.com
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Sharley » 17. October 2011 03:32

I have entered you details in red and commented out the parts that you uncommented in error
; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=send.one.com

; smtp port (normally 25)

smtp_port=2525 ;your smtp port mentioned above.

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=local

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

;error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

;debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=private ;your username here
auth_password=private ;your password here

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines

;pop3_server=
;pop3_username=
;pop3_password=

; to force the sender to always be the following email address, uncomment and
; populate with a valid email address. this will only affect the "MAIL FROM"
; command, it won't modify the "From: " header of the message content

force_sender=me@localhost ;your email address at one.com

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting. you can manually set the ehlo/helo name if required

;hostname=localhost


You did not paste the full Mail Function section so here is the recommended settings to work with sendmail
[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\php\logs\php_mail.log"
Try that and see how it goes and don't forget to save the files and restart Apache.
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: Problem with sending mail

Postby hunkysomi » 17. October 2011 04:02

Is this right for the php.ini

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = send.one.com
; http://php.net/smtp-port
smtp_port = 2525

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = sal@attilariskmanagement.com

; 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\php\logs\php_mail.log"
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby hunkysomi » 17. October 2011 04:04

restarting apache server is same as refreshing from the control panel right.
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Sharley » 17. October 2011 04:11

hunkysomi wrote:Is this right for the php.ini
No
Sharley wrote:
[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\php\logs\php_mail.log"


hunkysomi wrote:restarting apache server is same as refreshing from the control panel right.
Actually Stop and the Start Apache from the Control Panel to be sure.
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: Problem with sending mail

Postby hunkysomi » 17. October 2011 04:20

when i click stop apache, there is busy message and it is still running. so i went to services and manaully restarted it.

do you know why i cant stop it from control panel.

btw it did work, and i receive email as well. But i still get this line when i open the page

Notice: Undefined index: username in C:\xampp\htdocs\Attila\contact.php on line 98
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Sharley » 17. October 2011 04:30

hunkysomi wrote:when i click stop apache, there is busy message and it is still running. so i went to services and manaully restarted it.
Remove the Tick next to Apache, normally you don't need to start Apache at boot if developing and so removing the tick should uninstall the Windows Apache2.2 service, you can do the same for MySQL.

If there is still a problem then run as an administrator (right click) this bat file in the Apache folder:
apache_uninstallservice.bat

hunkysomi wrote:btw it did work, and i receive email as well. But i still get this line when i open the page

Notice: Undefined index: username in C:\xampp\htdocs\Attila\contact.php on line 98
This is an error-reporting setting in the php.ini file that you can change
Code: Select all
; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL | E_STRICT
Change it to what you like or to
Code: Select all
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
Which will show all errors but not Notices or Warnings etc. that should not present problems during the normal running of your server (you can change this setting again if you find that PHP is presenting unexplained issues to show you the warnings or notices), or you can edit the php code if you know how and what to change or if not then see if the script's author has updated the script.

You may find the solution to your line 98 script notice in these Google search results.
As usual save the file and restart Apache.

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: Problem with sending mail

Postby Altrea » 17. October 2011 04:33

Or change the sourcecode a little bit to get rid of this notice completely.

P.S.: If you would like to change the error_reporting setting in the php.ini i would recommend a different value for this, because hiding warnings can make debugging php very difficult:
Code: Select all
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with sending mail

Postby hunkysomi » 17. October 2011 05:22

Yes that annoying message does not appear anymore. Even i noticed phpformgenerator is working now. Many thanks and much appreciated.
hunkysomi
 
Posts: 7
Joined: 17. October 2011 00:05
Operating System: windows 7 Home

Re: Problem with sending mail

Postby Altrea » 17. October 2011 05:25

That are great news :D
Hope you enjoy XAMPP and all that stuff 8)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8286
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Re: Problem with sending mail (Win7) 1.7.7 [SOLVED}

Postby Sharley » 17. October 2011 05:40

Thanks for the feedback. 8)

I can now mark this topic as SOLVED.

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 34 guests