Problem with mail() (Windows XP SP3) 1.7.7

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

Problem with mail() (Windows XP SP3) 1.7.7

Postby atriant » 09. October 2011 16:38

Hallo!!
Please answer me if you Know. There are the followings files in my root Webserver but no email sent it.
In my localhost (XAMPP) everything is OK. Thanks


feedback.html

<html>
<head>
<title>E-Mail Form</title>
</head>
<body>

<form action="sendmail.php" method="POST">
<p><strong>Name:</strong><br> <input type="text" size="25" name="name" /></p>
<p><strong>E-Mail Address:</strong><br />
<input type="text" size="25" name="email" /></p>
<p><strong>Message:</strong><br />
<textarea name="message" cols="30" rows="5"></textarea></p>
<p><input type="submit" value="send" /></p>
</form>

</body>
</html>

--------------------------------------------------------
sendmail.php
<html>
<head>
<title>Sending mail from the form</title>
</head>

<body>

<?php
echo "<p>Thank you, <b>".$_POST["name"]."</b>, for your message!</p>";
echo "<p>Your e-mail address is: <b>".$_POST["email"]."</b>.</p>";


echo "<p>Your message was:<br />";
echo $_POST["message"]."</p>";
//start building the mail string
$msg = "Name: ".$_POST["name"]."\n";
$msg .= "E-Mail: ".$_POST["email"]."\n";
$msg .= "Message: ".$_POST["message"]."\n";
//set up the mail
$recipient = 'mail@1epal-mytil.les.sch.gr';
$subject = "Form Submission Results";
$mailheaders = "From: My Web Site <defaultaddress@yourdomain.com> \n";
$mailheaders .= "Reply-To: ".$_POST["email"];
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>

</body>
</html>
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail()

Postby Sharley » 09. October 2011 17:08

What version of XAMPP and which Operating System are you using?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
XAMPP Version: 5.6.3
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Problem with mail()

Postby atriant » 11. October 2011 09:49

My webserver doens't provide mail(). He advised me to use PhpMailer. In it's page i don't understand so much. Can you guide me step by step. I must tell you that i have install Xampp. Thank you.
Last edited by Sharley on 11. October 2011 09:55, edited 1 time in total.
Reason: Please post in English only!
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail()

Postby Sharley » 11. October 2011 09:59

Important info required as the reply is version specific.
Sharley wrote:What version of XAMPP and which Operating System are you using?
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
XAMPP Version: 5.6.3
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Problem with mail()

Postby atriant » 11. October 2011 14:24

I use XAMPP 1.7.7 and Windows XP SP3

Step by step please!!
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail()

Postby Sharley » 11. October 2011 20:34

Instructions to configure sendmail in XAMPP 1.7.7 as requested. :)

This method using sendmail is usually required because your ISP requires authentication ie. user/pass combo before you can send email and most settings below in the sendmail.ini can be found in your regular email client - the one you use all the time to send and receive email on your PC.


Assuming you installed XAMPP to the default location open in a text editor C:\xampp\php\php.ini file and change the lines in red so they they look like this:
[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"



Edit the C:\xampp\sendmail\sendmail.ini file in your text editor.

Settings in red can be found in your usual email client like Outlook Express etc.
; 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= Put your ISP email server here

; 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=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= same as in your Windows email client
auth_password= same as in your Windows email client


; 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= your email address at your ISP

; 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
Save both files and restart Apache.


To test these settings 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 by typing in the address bar:
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?

If this is successful then try your own script and see if it sends an email.


Good luck and please let me know if the solution is successful.

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

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby atriant » 12. October 2011 10:29

The output from mailtest.php is bool(true).

The file debug.log is
11/10/12 08:52:47 ** --- MESSAGE BEGIN ---
11/10/12 08:52:47 ** To: you@comcast.net
11/10/12 08:52:47 ** Subject: testmail
11/10/12 08:52:47 **
11/10/12 08:52:47 ** This is a testmail.
11/10/12 08:52:47 ** --- MESSAGE END ---
11/10/12 08:52:47 ** Connecting to mail.sch.gr:25
11/10/12 08:52:47 ** Connected.
11/10/12 08:52:47 << 220 mail01z1.att.sch.gr ESMTP Postfix<EOL>
11/10/12 08:52:47 >> EHLO server<EOL>
11/10/12 08:52:47 << 250-mail01z1.att.sch.gr<EOL>250-PIPELINING<EOL>250-SIZE 30000000<EOL>250-VRFY<EOL>250-ETRN<EOL>250-STARTTLS<EOL>250-AUTH PLAIN LOGIN<EOL>250-AUTH=PLAIN LOGIN<EOL>250-ENHANCEDSTATUSCODES<EOL>250-8BITMIME<EOL>250 DSN<EOL>
11/10/12 08:52:47 ** Authenticating as 1epal-mytil
11/10/12 08:52:47 >> AUTH LOGIN<EOL>
11/10/12 08:52:47 << 334 VXNlcm5hbWU6<EOL>
11/10/12 08:52:47 >> MWVwYWwtbXl0aWw=<EOL>
11/10/12 08:52:47 << 334 UGFzc3dvcmQ6<EOL>
11/10/12 08:52:47 >> MXRlbXl0NTk=<EOL>
11/10/12 08:52:47 << 235 2.7.0 Authentication successful<EOL>
11/10/12 08:52:47 >> MAIL FROM: <mail@1epal-mytil.les.sch.gr><EOL>
11/10/12 08:52:47 << 250 2.1.0 Ok<EOL>
11/10/12 08:52:47 >> RCPT TO: <you@comcast.net><EOL>
11/10/12 08:52:47 << 250 2.1.5 Ok<EOL>
11/10/12 08:52:47 >> DATA<EOL>
11/10/12 08:52:47 << 354 End data with <CR><LF>.<CR><LF><EOL>
11/10/12 08:52:47 >> Date: Wed, 12 Oct 2011 08:52:47 +0300<EOL>
11/10/12 08:52:47 >> To: you@comcast.net<EOL>
11/10/12 08:52:47 >> Subject: testmail<EOL>
11/10/12 08:52:47 >> <EOL>
11/10/12 08:52:47 >> This is a testmail.<EOL>
11/10/12 08:52:47 >> .<EOL>
11/10/12 08:52:47 << 250 2.0.0 Ok, id=18043-07, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as A0CEF93F8F<EOL>
11/10/12 08:52:47 >> QUIT<EOL>
11/10/12 08:52:47 << 221 2.0.0 Bye<EOL>
11/10/12 08:52:47 ** Disconnecting from mail.sch.gr:25
11/10/12 08:52:47 ** Disconnected.
11/10/12 08:52:47 ** Disconnected.

No spams are there.
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby Sharley » 12. October 2011 10:37

That looks good, did you check that the message arrived at your inbox at you@comcast.com because it was successfully sent there
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
XAMPP Version: 5.6.3
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby atriant » 12. October 2011 18:45

The output from mailtest.php is bool(true).
The message doesn't exits in my inbox
I sent my files. Please check them...

Php.ini
*************************************
mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = mail.sch.gr
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = mail@1epal-mytil.les.sch.gr

; 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"
**********************************************************

sendmail.ini
***********************************************************
[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=websitemail

; 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=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=username
auth_password=password

; 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=you@sch.gr

; 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
******************************************************************
mailtest.php

<?php
error_reporting(E_ALL);
var_dump(mail('you@comcast.net', 'testmail', 'This is a testmail.'));
?>
**********************************************************************
Αποστολή email μέσω PHP script
Διακομιστής αλληλογραφίας (Host ή Server) websitemail
Usename me
user email you@sch.gr
Password mypass
****************************************************************
Thank you
Last edited by Sharley on 12. October 2011 20:36, edited 1 time in total.
Reason: replaced real email address, passwords and usernames
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby Sharley » 12. October 2011 21:14

In the mailtest.php replace you@comcast with your real email address that you put in this line force_sender=you@sch.gr in the sendmail.ini file, as this test script uses sendmail.ini to find your details.

Test again.

For those who do not speak Greek:
Αποστολή email μέσω PHP script
Διακομιστής αλληλογραφίας (Host ή Server) websitemail
Usename me
user email you@sch.gr
Password mypass
Translated
Send email using PHP script
Mail server (Host or Server) websitemail
Usename me
user email you@sch.gr
Password mypass



VERY IMPORTANT
Best not to post your real email address, user names or passwords in a forum but in the configuration files you must use your real details.
:)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
XAMPP Version: 5.6.3
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby atriant » 13. October 2011 07:26

Again It doen't sent anytning , only the message bool(true).
atriant
 
Posts: 6
Joined: 09. October 2011 16:29

Re: Problem with mail() (Windows XP SP3) 1.7.7

Postby Sharley » 13. October 2011 08:20

Read the error.log file and the debug.log file in the sendmail folder as the bool(true) indicates it has sent the mail.

Your address may be wrong as it should be the same as the address you are collecting the mail from (pop) or your ISP may be blocking port 25 and so you need to check which alternative SMTP is allowed and change that in the sendmail.ini file.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
XAMPP Version: 5.6.3
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 44 guests