Using Mercury mail to send mails

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

Using Mercury mail to send mails

Postby ReiKo » 15. October 2010 20:52

Hello,

I'm currently using full version of latest XAMPP. I'm pretty new in PHP but I did simple script that should work but I can't get it right (it seems). Basically I'm just trying to submit message and then send it to the Gmail mail.

I configured new user in Mercury (that part of XMAPP is ON as is Apache server) but still I always get 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\xampp\htdocs\xampp\Test\Mail.php on line 2


I uncommented (in php.ini) [mail function] and added modified parameter in Mercury.

Can someone help me?

Thank you.
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23

Re: Using Mercury mail to send mails

Postby JonB » 16. October 2010 02:16

did you make Mercury a service?

:?:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Using Mercury mail to send mails

Postby Dariusc123456 » 16. October 2010 03:01

In your php.ini make sure this code is there

Code: Select all
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Using Mercury mail to send mails

Postby ReiKo » 16. October 2010 08:18

Dariusc123456 wrote:In your php.ini make sure this code is there

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


Yes, it's by default that way. Here are my settings:

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 = ReiKo@localhost

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path = "\"C:\XAMPP\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\xampp\apache\logs\php_mail.log"

[SQL]
; http://php.net/sql.safe-mode
sql.safe_mode = Off

[ODBC]
; http://php.net/odbc.default-db
;odbc.default_db    =  Not yet implemented


Mecrury is run as a service. But when I run portcheck via XAMPP i see MErcury SMTP 25 port is free (SMTP) and POP3 110 port is also free...

It seems I need to run Mercury Client via doubleclick from folder it doesen't run from XAMPP menu...hmm..

Maybe it would be good if you hook me up with some kind of test-tutorial for Mercury? I Googled but couldn't find anything of use (php script + configuration for XAMPP Mercury) just to be sure I configed other parts right.
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23

Re: Using Mercury mail to send mails

Postby Dariusc123456 » 16. October 2010 16:19

I myself dont recommend mercury. I recommend hMailServer. Also make the settings in mercury has all the ports enter
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Using Mercury mail to send mails

Postby ReiKo » 16. October 2010 17:19

Also, when running Mercury in Windows 7...

Before Vista all users were on session 0. I understand this caused a lot of security problems. Windows on Vista started using different session for different users. And developed something called Interactive Services Detection service.

This ISD thingie is preventing Mercury from runing as service in Windows 7.

Can I use hMailServer with XAMPP, Darius? Care to explain how to configure it and test it?


Thanks.
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23

Re: Using Mercury mail to send mails

Postby Dariusc123456 » 16. October 2010 18:13

Yes, you can use it and its very simple. All you need todo is follow the installation, enter your mysql information in and it will make a new database to store all your email accounts, and you just login and work from there. Easy and simple. Mercury doesnt allow mutliple domain entries when I tried it and I had a hard time getting it to send and receive email, and it had some security issues with spam. hMailServer has the tools needed to stop spam, scan sent or receive mail for viruses and you can use its api with PHP to build it into your own cpanel, or work from there.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Using Mercury mail to send mails

Postby ReiKo » 16. October 2010 18:40

Dariusc123456 wrote:Yes, you can use it and its very simple. All you need todo is follow the installation, enter your mysql information in and it will make a new database to store all your email accounts, and you just login and work from there. Easy and simple. Mercury doesnt allow mutliple domain entries when I tried it and I had a hard time getting it to send and receive email, and it had some security issues with spam. hMailServer has the tools needed to stop spam, scan sent or receive mail for viruses and you can use its api with PHP to build it into your own cpanel, or work from there.


But how can I use it with PHP? I'm just learning PHP so I want to use for example hMailServer to send mail using PHP. Is that possible?
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23

Re: Using Mercury mail to send mails

Postby Dariusc123456 » 16. October 2010 19:05

Simple, just use the mail() function and then it should work. I also think you should uncomment the smtp_port in php.ini to make use sending mail via port 25 in php.

Here is a code to help you send mail in PHP

Code: Select all
function mailto($to, $from, $subject, $message){
$headers = 'From: '.$from.'' . "\r\n" .
    'Reply-To: '.$from.'' . "\r\n" .
    'X-Mailer: PHP/' . phpversion() . "\r\n" .
    'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1' . "\r\n";
return mail($to, $subject, $message, $headers);
}


Basic but its useful for someone like you.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Using Mercury mail to send mails

Postby ReiKo » 16. October 2010 19:40

Yes, thanks I will try it out and test it to see how it works.

Also, by uncomenting you mean to remove ";" before statement in php.ini?
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23

Re: Using Mercury mail to send mails

Postby Dariusc123456 » 16. October 2010 19:47

ReiKo wrote:Hmmm what about "mail()" function? In this code I see only "mailto()" function. I presume I could use "mail (to,from,subject,message)" function also?


Seeing your still new, this is a PHP Function. Place

Code: Select all
function mailto($to, $from, $subject, $message){
$headers = 'From: '.$from.'' . "\r\n" .
    'Reply-To: '.$from.'' . "\r\n" .
    'X-Mailer: PHP/' . phpversion() . "\r\n" .
    'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1' . "\r\n";
return mail($to, $subject, $message, $headers);
}


into your php file, and in same php file use

Code: Select all
mailto("to@example.com", "from@example.com", "subject", "message");


but replace the information in that function to send the mail to the right place.

If you want to use the mail function itself, just use
Code: Select all

$to = '';
$from = '';
$subject = '';
$message = '';

$headers = 'From: '.$from.'' . "\r\n" .
    'Reply-To: '.$from.'' . "\r\n" .
    'X-Mailer: PHP/' . phpversion() . "\r\n" .
    'MIME-Version: 1.0' . "\r\n" .
    'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 mail($to, $subject, $message, $headers);


Also make sure you uncomment the smtp_port in the php file or in your php script add

Code: Select all
ini_set('smtp_port', '25');
to make the smtp port 25.
Dariusc123456
 
Posts: 22
Joined: 15. October 2010 15:18

Re: Using Mercury mail to send mails

Postby ReiKo » 16. October 2010 22:33

Solved, thanks Darius.
ReiKo
 
Posts: 6
Joined: 15. October 2010 20:23


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 50 guests