send emails in php
Posted by: Ares (---.static.as13285.net)
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 outmail.f2s.com. Should now be mail.overssl.net". My email used to be handled by outmail.f2s.com port 25 but is now mail.overssl.net. The error suggest setting the correct parameters in php.ini or using ini_set. Anyone know how to do this.

Options: ReplyQuote
Re: send emails in php
Posted by: Ares (---.static.as13285.net)
Date: July 02, 2022 12:48PM

I have now learned to set php parameters using:
ini_set('SMTP','mail.overssl.net');
ini_set('smtp_port', '999'; (using mu correct output port number)
ini_set('sendmail_from','myemail@domain.com'); (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?

Options: ReplyQuote
Re: send emails in php
Posted by: maximus23 (---.dynamic.voo.be)
Date: July 02, 2022 02:47PM

Hi,

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

Please consult this link: [websitetutorials.grafix.gr]


smiling smiley

Options: ReplyQuote
Re: send emails in php
Posted by: Ares (---.static.as13285.net)
Date: July 08, 2022 04:04PM

Thanks. Will do.

Options: ReplyQuote
Re: send emails in php
Posted by: Ares (---.static.as13285.net)
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) :
$emailTo="rogerkeeling@f2s.com";
$emailSubject="Email Subject";
$fullMessage="email message";
$attachments="";
ini_set('SMTP','b.mx.nildram.net');
ini_set('smtp_port', '25');
ini_set('sendmail_from','rogerkeeling17@gmail.com'); # works ok: from and to email addresses handled correctly
#ini_set('sendmail_from','rogerkeeling@f2s.com'); #appears to work (no error reported) but no email arrives
$ok=mail($emailTo,$emailSubject,$fullMessage,$attachments);
echo ("rwk1".$ok."rwk2"winking smiley;
}

This works OK if sender is rogerkeeling17@gmail.com 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.

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

Hi,

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

Options: ReplyQuote
Re: send emails in php
Posted by: Ares (---.static.as13285.net)
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.

Options: ReplyQuote
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 3.2.5.4
<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-

Options: ReplyQuote


Sorry, only registered users may post in this forum.