Help needed to get PHP mail() to work

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Tue May 31, 2022 9:02 am    Post subject: Help needed to get PHP mail() to work Reply with quote

Hello, folks,

This is NOT an Abyss problem, but I believe that it is caused by my PHP that I am using with Abyss, and hopefully some of you PHP experts can tell me where to look for the problem.

I have a Guestbook PHP script that I've been using for years when my sites were being hosted externally, and it worked great. I have since had to bring all of my sites in-house & am now hosting them on Abyss X2 on Windows, with most hosts using PHP 8.1.0 but a few needing to still use PHP 7.x

The Guestbook that I'm using sends me email notifications using PHP mail(), but I think that I have something not configured correctly in my php.ini file.

Reading through the posts on the guestbook forums, all related posts point to the users' PHP mail() not being configured correctly.

In my php.ini file, I've tried setting my SMTP server, SMTP Port, and sendmail_from email address, but still no luck.

I found on the Internet some code that I used to create a test php file to test sendmail, and it fails, due to my SMTP server requiring authentication in order for me to use it to send emails, but there is no place (that I can see) in php.ini for me to enter in my SMTP login credentials, not that I would want to.

How do other Abyss users (who use Abyss on Windows) manage to use PHP mail() to send out emails?

Sorry for being so long-winded.

Thanks in advance,

John
Back to top View user's profile Send private message Visit poster's website
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Tue May 31, 2022 9:36 am    Post subject: Reply with quote

OK, so I've learned now that PHP mail() does not support authentication. Which I would think makes PHP mail() useless to almost everyone these days, as there's quite likely not many mail servers remaining out there that do not require authentication.

So now I've come across something called PHPMailer, which I downloaded & read the ReadMe file, but PHPMailer requires a PhD in order to follow the instructions on how to install & configure it, unfortunately.

So I guess I'm SOL.
Back to top View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1246

PostPosted: Thu Jun 02, 2022 10:37 pm    Post subject: Reply with quote

JMMotyer,

PHPMailer is your best friend when it comes to sending emails on PHP. It may seem overly complicated but it is only mirroring the current state of mail complexity. SMTP has been around for almost half a century and the protocol is getting layers over layers of new features.

How about checking the examples in https://github.com/PHPMailer/PHPMailer/tree/master/examples ? You don't need to understand all the details. Gmail's sending example is probably the most complex setup you may encounter and it's very readable.

Alternatively, please let us know what parameters your mail gateway requires (for an email client) and we'll let you know how to replicate the settings for PHPMailer.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Fri Jun 03, 2022 1:13 am    Post subject: Reply with quote

Hello, and thanks for getting back to me.

I have no idea if PHPMailer will accomplish & fix the problem that I'm having.

Please let me explain. I've been using a PHP script for 16 years for my Guestbook. Why? I don't know, as only 6 people have signed it in 16 years :-). The way it works is, when someone leaves a comment in that guestbook, the PHP guestbook script sends me an email to notify me that someone has signed it, so I can then either approve or delete the entry. Without that email, I have no idea that someone has left a comment, and therefore their comment remains in limbo.

Up until earlier this year, most of my sites were hosted externally, and that hosting company's system would send out those mail() notification emails without any problem. However, now due to me being retired & having a limited income, I had to bring all my sites in-house, all hosted by Abyss X2.

Unfortunately, that guestbook script relies solely on PHP's mail() function to send out the notification emails to me; there is no option to include SMTP authentication details in the script.

So what I would need to accomplish, somehow, is for that guestbook script to continue to send out the notification emails using PHP's mail(), but somehow have PHPMailer send the emails out. Is that possible?

The other problem that I might have is, I am running more than 1 flavour of PHP: PHP 7.2.28 (due to CMS limitations), and PHP 8.1.0, both in their own Windows subdirectories, with each of Abyss X2's hosts pointing to whichever flavour of PHP that they need.

If PHP mailer can indeed intercept & send out the notification emails instead of mail(), would I need 2 separate installations of PHPMailer, or would a single installation of PHPMailer suffice?

I have no idea how I did it, but yesterday I got PHPMailer to send out a couple of test emails successfully to me, but that was by creating a test PHP file that used PHPMailer to send out the test emails. As mentioned, I have no idea if it is even possible, or how to accomplish it if it is indeed possible, to have the guestbook PHP script send out the notification emails using mail(), but the notification emails actually sent out using PHPMailer. Is that indeed possible?

I am not a developer, I know just enough to get the automatic Abyss to work for me :-).

Thanks in advance, and have a great day.

Regards,
John
Back to top View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 03 Mar 2002
Posts: 1246

PostPosted: Sun Jun 05, 2022 9:11 pm    Post subject: Reply with quote

JMMotyer,

There are two solutions:

The first is to have a kind of mail relay software which will run on your server, get emails sent on port 25 without any authentication (as those sent by PHP's mail() function) and then relay them to the actual SMTP server with authentication.

The second solution is purely software. It consists in writing a function equivalent to PHP mail() but which uses PHPMailer as its backend to sending messages.

Are you on macOS? What is the kind of SMTP server you'll have to connect to for sending emails? What are its parameters?

These questions will help us decide if solution 1 is possible for your situation.
_________________
Follow @abyssws on Twitter
Subscribe to our newsletter
_________________
Forum Administrator
Aprelium - https://aprelium.com
Back to top View user's profile Send private message
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Sun Jun 05, 2022 11:20 pm    Post subject: Reply with quote

Hello good folks at Aprelium,

Now I know the proper description of what I need & am looking for: Mail Relay.

I am running Abyss X2 locally on Windows 10. It's a dedicated PC, with only Abyss on it, along with PHP & MySQL.

Do I need an actual SMTP server installed, or can I use my existing mailbox which is hosted by an external company (Dotster)? The problem with my mailbox on Dotster is, it requires login authentication, which is why it is not working for mail ().

I tried installing hMailServer, but it configured itself to use IIS on my Abyss PC, and then Abyss stopped listening on port 80 for all my hosts, so I immediately uninstalled hMailServer.

Your solution # 1 for me would be the best solution, as the PHP scripts that I am using to send out using mail() are written by other developers, and I cannot change the method that they use to send out emails, and they are unwilling to modify their scripts to use SMTP authentication.

Since your post today, I have tried E-MailRelay and MgSMTP, but they did not work, and I have no idea if they are what I need.

I was hoping that there would be other Abyss users with limited knowledge in these matters such as myself, who have found a work-around in getting mail() to work for their needs.

Thank you in advance, and as always truly appreciate your suggestions & help.

Regards,
John
Back to top View user's profile Send private message Visit poster's website
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Mon Jun 06, 2022 1:04 pm    Post subject: Reply with quote

No need to spend any more time on this issue, as it is too much above my comprehension, and seems like I have to create a new CPU chip to just add 1+1 :-). I can do without a guestbook.

Thanks everyone for the suggestions to date on this topic.

Have yourselves a great day & be safe.

Regards,
John
Back to top View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 941
Location: Michigan, USA

PostPosted: Tue Jun 07, 2022 8:08 pm    Post subject: Reply with quote

Unfortunately, the web used to be simple... until spam came along.

The easiest solution I can come up with is setting up a mail server locally. You could even give it a hostname on the internet, like mail.mydomain.net. Know that your server most likely won't be able to send mail to the outside world, since most ISPs block outbound port 25 (which is used for SMTP to send emails). You could use PHPMailer to send emails to your local server.

Then you could set up your phone or tablet's mail app to retrieve mail from your local mail server.

Other than that, there is nothing easy. I personally use Pushover for notifications to my phone. It is very low cost ($5 one-time cost for each platform -- browser / iOS / Android). To send alerts to your phone, you only need to send a POST request to a specific URL. This would work if you can intercept the mail routine of your guestbook script and change it to a PHP cURL request.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
JMMotyer
-


Joined: 06 Jul 2005
Posts: 43
Location: Burlington (Toronto), Ontario, Canada

PostPosted: Fri Jun 10, 2022 7:50 am    Post subject: Reply with quote

Hi again, Stephen,

Thanks for your suggestions, however, as this is for an out-of-the-box script, I cannot change the code that it uses to send out notifications via mail(), due to my lack of knowledge.

To get around this, I just wrote an MS-DOS batch file to check for submissions & scheduled it to run at midnight every night, and this method works perfectly for my needs :-).

Thanks again for your suggestions, though.

Regards,
John
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group