PHP mail

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

PHP mail

Postby safiVA » 06. February 2011 02:18

Hi,

I have xampp/eclipse/windowsxp. below code does not send any email. I dont know whether i need to do something with php.ini file. or i need mail server. I am new to this.

When i run the following code in eclipse, i get message saying Mail Sent but i never get any message in hotmail(not even in gmail ). I am not sure why?
<?php
$to = "safiullah12@hotmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "safiullah12@hotmail.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>


Pls help.

Thx.
safiVA
 
Posts: 8
Joined: 31. January 2011 02:34

Re: PHP mail

Postby safiVA » 06. February 2011 03:54

installed directory as follows:
php.ini > c/program files/xampp/php/php.ini
sendmail > c/program files/xampp/sendmail/sendmail.ini
xampp > c/program files/xampp
eclipse > c/program files/eclipse

what works:
http://localhost/xampp/

does not work.
http://localhost/aaa/sendMail.php
if i run this php file, i get msg saying msg sent but i never got the email.

I am not sure how i can set up the sendmail.ini and php.ini file. Pls help. thanks.
safiVA
 
Posts: 8
Joined: 31. January 2011 02:34

Re: PHP mail

Postby WilliL » 06. February 2011 12:37

of course you'll get allways the information that mail was sent for you forced it in your code
Code: Select all
mail($to,$subject,$message,$headers); // may be work fine or not
echo "Mail Sent.";                    // echo success ;)


Code: Select all
if(mail($to,$subject,$message,$headers)) {
            echo 'mail was sent';
} else {
            echo 'an error occured: mail was not sent';
}

If there is an error, have a look to errorlog.
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP mail

Postby safiVA » 06. February 2011 15:47

thanks.

my code now:
<?php
$to = "safiullah12@hotmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "safiullah12@hotmail.com";
$headers = "From: $from";
if(mail($to,$subject,$message,$headers)) {
echo 'mail was sent';
} else {
echo 'an error occured: mail was not sent';
}

?>


once i run it in eclipse, i get "mail was sent" right away but i never got email. i thought it will take some time to process the request to give me the result. thats not the case. i click run and i get answer in sec.
no error message there. so i cant even trouble shoot.
Pls help. i spent many hours. still no luck.
Thanks.
safiVA
 
Posts: 8
Joined: 31. January 2011 02:34

Re: PHP mail

Postby WilliL » 06. February 2011 19:13

which XAMPP Version are you using?
do you use sendmail od mercury? have you ever configurated them?

http://community.apachefriends.org/f/viewtopic.php?f=16&t=44384&p=173414&hilit=sendmail#p173414
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1

Re: PHP mail

Postby safiVA » 06. February 2011 22:27

xamp 1.7.4
i see sendmail : C:\Program Files\xampp\sendmail

i have configurated something.not sure whether it is correct. i can access local host fine. i think i need to do something with the mail server/php.ini/sendmail.ini

pls help!
thx.
safiVA
 
Posts: 8
Joined: 31. January 2011 02:34

Re: PHP mail

Postby safiVA » 07. February 2011 02:03

Php.ini shows:

[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

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:\Program Files\xampp\sendmail\sendmail.exe\" -t"

sendmail_path = "C:\Program Files\xampp\sendmail\sendmail.exe -t"


--------------------------------
sendmail.ini :

; 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=localhost

; 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
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=
;auth_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=me@localhost

force_sender=me@localhost

; 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
hostname=localhost
safiVA
 
Posts: 8
Joined: 31. January 2011 02:34

Re: PHP mail

Postby WilliL » 08. February 2011 20:29

Php.ini
Code: Select all
[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:\Program Files\xampp\sendmail\sendmail.exe\" -t"

sendmail_path = "\"C:\Program Files\xampp\sendmail\sendmail.exe\" -t"



sendmail.ini :
Code: Select all
[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=mail.yourdomain.de

; 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
; to see what happens if it doesn't work

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

;auth_username=
;auth_password=

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

pop3_server= mail.yourdomain.de
pop3_username= your_login_username
pop3_password= your_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=yourmail@yourdomain.de

; 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=yourdomain.de


this could work, but must not..
In my case it doesn't work on 1.7.4 because (actual errors form debug.log):
Recipient address rejected: temporarily blocked because of previous errors - retrying too fast. penalty: 30 seconds x 0 retries
OR
Recipient address rejected: Mail appeared to be SPAM or forged. Ask your Mail/DNS-Administrator to correct HELO and DNS MX settings or to get removed from DNSBLs; MTA helo: willi-lt, MTA hostname: p5087ea7c.dip.t-dialin.net[80.135.234.124] (helo/hostname mismatch)<EOL>

I've no idea whats the reason, perhaps an helo error in sendmail delivered with xampp 1.7.4?

I copied sendmail folder from XAMPP 1.7.3 into the folder of XAMPP 1.7.4 and it works perfect :shock: - i'm puzzled
Willi
WilliL
 
Posts: 661
Joined: 08. January 2010 10:54
Operating System: Win7Home Prem 64 SP1


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 47 guests