Page 1 of 1

SMTP for the Mail fucntion in PHP

PostPosted: 30. August 2007 00:27
by adaykin
Hello, I am trying to use the Mail function in PHP, but I am not sure how to set up either the PHP.ini file or the SMTP.ini file to do so. I tried using the function but I ran into this error message:

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\xampp\eclipsePHP\formSubmit.php on line 52

PostPosted: 30. August 2007 04:22
by Izzy
In the xampp\apache\bin\php.ini find near line 693:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

Change to:

[mail function]
; For Win32 only.
SMTP = smtp.myispmailserver.com
(your ISP's smtp mail server - the one you use in your email client eg. Outlook Express etc.)
smtp_port = 25 (the port you use for sending mail via your ISP as above)

SMTP.ini ? - no such file in XAMPP

If you select sendmail in your script then you would set up Sendmail in XAMPP:
xampp\sendmail\sendmail.ini
in much the same way as above.

Localhost is used usually if you have a mail server set up on your PC to send/receive mail via localhost, which most ISPs don't allow these days, and most receiving Mail Exchanges block without a dedicated IP/Domain name combo.

So best sticking with either the php.ini or the Sendmail method above, much simpler and does the trick for most php scripts.
HTH

=================================================
Take a look at the new DeskTopXampp launch control posted by ridgewood:
http://community.apachefriends.org/f/viewtopi ... 967#103967

The DeskTopXampp launch control for XAMPP and XAMPPlite (DTX.exe)
is available here:
http://zedfiles.com/DTX/

I highly recommend DTX.
=================================================

PostPosted: 01. September 2007 14:56
by lyntuan
PHP mail function only works with smtp mail server, but not works with smtp auth mail server as GMail or Yahoo (POP before smtp)

PostPosted: 06. September 2007 18:19
by crayons
just curious. what does desktop xampp do?

PostPosted: 07. September 2007 02:14
by Izzy
crayons wrote:just curious. what does desktop xampp do?


http://nat32.com/dtx/

The DTX Launcher lets you start Apache and MySql from any USB storage device.
It requires no configuration, although some customization can be done by editing a simple ini file.

=================================================
Take a look at the new DeskTopXampp launch control for XAMPP and XAMPPlite (DTX.exe)
http://nat32.com/dtx/
posted by ridgewood:
http://community.apachefriends.org/f/viewtopi ... 967#103967
Also available here: http://zedfiles.com/DTX/
I highly recommend DTX.
=================================================

Warning: mail() [function.mail]: SMTP server response: 551

PostPosted: 18. September 2007 17:26
by mikesz
Warning: mail() [function.mail]: SMTP server response: 551 User not local; please try <forward-path> in C:\xampp\htdocs\testmail.php on line 11

Hello, I am wondering is anyone has a clue what this source of this problem is?

I am trying to get php mail() to work with xampp that I just installed. I have used the form to send email via mercurymail and it works perfectly but any attempt to try to use php mail directly in a script produces this error message and of course fails to send the message.

My test script is a no brainer actually:

$mailtos = "webmaster@mydomain.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "postmaster@mydomain.com";
$header = "From: $from";
if (mail($mailtos, $subject, $message, $header)) {
echo "<i>mail-sendok</i>";
} else {
echo "<i>mail-sendnotok</i>";
}

I have used every reference I can think of to point the smtp in php.ini to my ISP server and nothing works? It did work correctly when I had Apache2Triad installed but xampp seems to have a problem with it.

Here is the php.ini piece, fyi:

[mail function]
; For Win32 only.
SMTP = mail.mydomain.com
smtp_port = 25


; For Win32 only.
sendmail_from = webmaster@mydomain.com


Any light at all will be greatly appreciated, kindest regards, mikesz