php unable to send mail - php

I'm trying to set up a php script to send an email on a server with a joomla installed, I got the some script working in other project and is working fine.
I'm using this script on a landing page separate from Joomla. I had check the phpinfo and this is what it's show.
mail.add_x_header On On
mail.force_extra_parameters no value no value
mail.log no value no value
sendmail_from no value no value
sendmail_path no value no value
I'm wondering if the joomla is interfering with the mail function of php or if the function is not properly set up in php.ini
Thank you!

I am sure there are lot of plugins you can install.
Or,
Try PHPMailer. I have used it in the past. It's very easy to implement.
https://github.com/PHPMailer/PHPMailer
Hope this helps.

It means you haven't correctly setup your mail server in Joomla!
To setup the mail server go to Global Configurations > Server > Mail settings
Choose the best option for your mail settings from the dropdown and setup!
If you have a cPanel, go to Mail section and find info about your email, authentication type and more!
Hope this helps!

Related

How to create email account on cpanel using php

I am trying to create email account in cpanel using php like test#mydomain.com. I tried cpanel api's , xml api etc.
fopen ("http://$cpuser:$cppass#$cpdomain:2083/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass&quota=$equota", "r");
this gives me error "Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode"
but not worked any more. can any one tell me what is the problem exactly, is there any settings I have to set up in server or any thing else.
thank you in advance :)
As the error suggests probably you have allow_url_fopen on the disabled_functions list on your php.ini (default location would be /usr/lib/php.ini).
Alternatively you can use the perl script provided by cPanel to create an email address from command line:
/scripts/addpop user#domain.com password quota#
Example:
/scripts/addpop contact#abc.com password 1024 (this will create the email address contact#abc.com with the password 'password' and with 1024M (1G) as quota
If you do want to use that in a php script then use the php shell_exec() function to execute the command above and you're good to go.
I would advise against enabling allow_url_fopen in php.ini long termn and leave it like that since it might pose security risks to your server.

Plesk 12 sendmail issues

First of this is my server configuration:
OS CloudLinux Server 6.7 (Aleksei Gubarev)
Plesk version 12.0.18 Update #65,
And now this is my problem.
I have disabled sendmail via panel, and set outoging mail limit 50 e-mail per inbox. Everything was working fine till recently when we started to have issues with mails.
Despite sendmail being disabled this works pretty good in command line
echo -e "To:test#mail.com \nSubject: Test mail from web\n\n Test mail from web via senmail\n" | sendmail -t -F root#web.domain.com
Php works fine to, via php script despite php mail function being disabled in php ini (/opt/alt/php54/etc/php.ini)
mail("test#mail.com","hello","test mail function");
And the worst thing is both of those methods ignore outgoing mail limit that is set in panel.
So basicly someone can hack one of our website and starts sending spam (which happened already).
My questions are simple. How to disable sendmail permanently and how to disable php mail function on whole server.
Ty in advance.
Here is the correct answer.
put disable_functions = "mail, sendmail, mailx" in php.ini.
If you use multiple php versions on server you have put that on every php.ini for each version.
In cloudlinux for instance location is
/opt/alt/php53/etc/php.ini
/opt/alt/php54/etc/php.ini

How can I stop apache to send emails which are triggered in a php loop for testing

Hi there I was testing php code and was sending mails to my self coz the loop was in AJAX call so i didn't find better way to test it. now i am getting thousands of emails in my gmail.
Do anyone know how to force kill the sendemail process from terminal to stop this emails send by apache.
Killing sendmail will effect other applications and your server.
A better solution would be to disable the mail function (Assuming your sending emails using PHPs mail function) only for your application.
To disable the mail function just for your application you can do this.
ini_set('disable_functions','mail'); //Place this in your PHP script
php_value disable_functions mail //Or place this in your .htaccess file
To disable the mail function for all your applications you can place the following line in your php.ini.
disable_functions = "mail"
Also, note that doing this might throw an error or warning depending on your coding.
Hope this helps.

PHP sendmail_path does not work

I have a Windows 2003 server with PHP 5.24 installed on it.
I have read several posts (including the PHP manual page) on the Internet that say that sendmail_path in php.ini can be set to use a program such as Fake Sendmail which has the ability to push the mail file to my MDaemon pickup directory. I have downloaded that program and attempted to use it.
The problem is that sendmail.exe never gets executed.
sendmail_path = c:\SendMail\sendmail.exe
To verify it, I setup a simple batch file that writes to test.log when executed and changed the sendmail_path to point to the batch file. I verified the batch file does indeed create my test file when run from the command line, but when I try to send mail, the file does not get created.
sendmail_path = c:\SendMail\test.bat
The batch file never gets called.
I have tried a number of different things such as creating sendmail.exe in a path of /usr/lib/sendmail in both the c: root as well as the PHP programs folder but cannot seem to force PHP to use my file.
I have also tried putting the path name in single and double quotes, but nothing works.
In my PHP mail test I get get a fail msg and my PHP logfile shows the mail attempt to be delivered, so I know the mail process is being called.
Looking for some suggestions as to what to try next.
Gave up on trying to redirect PHP mail and just configured my servers SMTP settings to accept it. Although I had wanted to have my MDaemon mail server handle the workload, this method will suffice for the limited use it will get.
You have syntax error in php.ini! Just copy php.ini-development to php.ini and set:
SMTP =
sendmail_from =
sendmail_path = "c:\SendMail\sendmail.exe -t"
Or fix error in php.ini. Enjoy

PHP Pear Mail - Include Path

I am working on a PHP project that uses PHP's built in mail function. I am adding the option to use Pear mail.
It seems that in most hosting environments, using:
require_once('Mail.php')
doesn't work which is what all of the examples I could find show. Writing the include path as:
require_once('/path/to/pear/Mail.php')
also doesn't seem to work. However, setting the include path like:
set_include_path('/path/to/pear/')
require_once('Mail.php')
does work. Because there is a configuration file in my app where this is stored and the config is used in most of my pages (not having to do with email), I am not sure if this is a good idea. My config file now has the values stored like this:
// pear smtp mail settings
set_include_path('/path/to/pear/');
define('PEAR_INCLUDE_PATH', 'Mail.php');
define('SMTP_HOST', 'ssl://smtp.gmail.com');
define('SMTP_PORT', '465');
define('SMTP_USER', 'username#gmail.com');
define('SMTP_PASS', 'password');
Is this going to create problems for me? How should I do this?
Thank you
Your pear include path should be set globally in your php.ini file -- if not, you have a broken pear/php installation.
But if you want to be extra-paranoid, you could ship a local copy of pear's Mail and Net_SMTP modules.

Categories