Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Mail() Function returning error 500 Internal Server

Tags:

php

I have no idea why this is happening... I get an error 500 internal server error every time I try to run this PHP code. This is the ONLY line of code (it used to be more; narrowed it down to this for testing).

Error logs have been of no help. Unfortunately. I have read the other topics posted about this - none of them helped.

ONLY code:

 <?php
 mail("[email protected]", "Test!", "Hello, there!");
 ?>
like image 505
Namone Avatar asked Mar 03 '26 12:03

Namone


1 Answers

You need to look into php error log. Post your logs here if you cant discern which logs are relevant. Most likely smtp settings are be blamed. mail function opens a socket connection. using smtp settings.

SMTP settings can be managed through ini or by :

ini_set('SMTP', 'smtphost'); 
ini_set('smtp_port', 25); 

The above settings are just for example, you need to have your own smtp settings. For example if you have Gmail account, you may use it send mail. It depends on your specific situation which smtp server you may want to use.

Here are Gmail SMTP settings . Also look at the documentation

like image 102
Scalable Avatar answered Mar 05 '26 02:03

Scalable



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!