send emails in php
Posted by: Ares (
Date: June 30, 2022 07:30PM

I am using the "mail()" function in php to send emails from a webpage running in WAMP on my laptop. This used to work but I now get a failure message "local host failed to connect to mailserver at Should now be". My email used to be handled by port 25 but is now The error suggest setting the correct parameters in php.ini or using ini_set. Anyone know how to do this.

Re: send emails in php
Posted by: Ares (
Date: July 02, 2022 12:48PM

I have now learned to set php parameters using:
ini_set('smtp_port', '999'; (using mu correct output port number)
ini_set('sendmail_from',''); (using my correct email)

But now the webpage in WAMP loops (at least 20 mins) waiting response from localhost
I'm running WAMP on Outlook though this is now obsolete.

Any ideas how to get mail() running on WAMP on a local laptop?

Re: send emails in php
Posted by: maximus23 (
Date: July 02, 2022 02:47PM


It is very easy to use the SMTP mode with sendmail.

Please consult this link: []

smiling smiley

Re: send emails in php
Posted by: Ares (
Date: July 08, 2022 04:04PM

Thanks. Will do.

Re: send emails in php
Posted by: Ares (
Date: August 27, 2022 10:51PM

Apologies for delay in looking at this. I'm using code (running in WAMP on my laptop, not tried on a genuine website) :
$emailSubject="Email Subject";
$fullMessage="email message";
ini_set('smtp_port', '25');
ini_set('sendmail_from',''); # works ok: from and to email addresses handled correctly
#ini_set('sendmail_from',''); #appears to work (no error reported) but no email arrives
echo ("rwk1".$ok."rwk2"winking smiley;

This works OK if sender is and receiver rogerkeeling@f2s,com.
But works only if receiver is rogerkeeling@f2s,com. I would like to send from rogerkeeling@f2s,com to any email address.

Re: send emails in php
Posted by: Otomatic (Moderator)
Date: August 28, 2022 09:27AM


The mail() function (<- link on documentation) in php returns:

Returns true if the mail was successfully accepted for delivery, false otherwise.
It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.

Moreover, as you can read in the documentation, the writing constraints and the parameters of the mail are extremely important and must be fully respected.

It would be easier to use a class like phpmailer.

Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Re: send emails in php
Posted by: Ares (
Date: August 30, 2022 02:46PM

Thanks. I'm getting a "true" response but no email arrives. I suspect I'm not setting the various parameters correctly and/or, as you suggest I'm breaking constraints on the message contents. I'll look into phpmailer which I hadn't heard of or maybe (fake) sendmail.

Re: send emails in php
Posted by: RiggsFolly (Moderator)
Date: August 30, 2022 02:53PM

The `mail()` function does not send mail it just passes it to a mail server, the one you have configured in yout `php.ini` file.

So if you dont have a mail server on your system you cannot use `mail()` to send mail.

(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Sorry, only registered users may post in this forum.