-   Linux - Newbie (
-   -   php cannot invoke msmtp (

gmail_cs 03-07-2011 10:08 AM

php cannot invoke msmtp
I want to use php for mailing on linux.But when I do it with"$a=`msmtp < /u1/ftp/mail.txt &`",it does not work.The mail.txt's contents are following:

Thank you.
This is a test mail.
Please pay attention to the two null lines.
I hope some answers.Thank you.

bathory 03-08-2011 04:31 AM

Hi and welcome to LQ,

Does msmtp works when invoked from CLI, like:

msmtp < /u1/ftp/mail.txt
Because it needs a smtp server in order to be able to send out emails. Have a look here to see how to configure it so it uses gmail, or your ISP's mail server as smtp server


gmail_cs 03-08-2011 09:50 AM

It does not work yet.
Thank you for your reply,#2.But it does not work yet .The .msmtprc's content is:
#Set default values for all following accounts
tls on
tls_trust_file /etc/pki/tls/certs/ca-bundle.crt
logfile ~/Mail/msmtplog

# Gmail service
account gmail
auth on
user niubl967
password passwd
#port 587
# A freemail service
#account freemail
#host smtp.freemail.example
#from joe_smith@freemail.example
#auth on
#user joe.smith
#password secret

# A second mail address at the same freemail service
#account freemail2 : freemail
#from joey@freemail.example

# The SMTP server of the provider.
#account provider
#host mail.provider.example
#from smithjoe@provider.example
#auth on
#user 123456789
#password my_password
# Set a default account
account default : gmail
Hope for help.

bathory 03-08-2011 12:17 PM



#port 587
AFAIK gmail uses port 587 to relay mail, so you need to uncomment the above line. Other than that your ~/.msmtprc looks good.
Also have a look at logs (~/Mail/msmtplog) to see if you find something.


gmail_cs 03-09-2011 01:46 AM

I have tried to cancel the "#",but it does not work.When I change the code with "$a=`msmtp --help`;",it return the help.But it does not work with other commands.

bathory 03-09-2011 02:54 AM


Please define "it does not work"
I've already told you to do your tests from CLI, so you'll see eventual errors either on screen, or in the log file created


gmail_cs 03-10-2011 08:41 PM

I can send a mail from CLI.A test code is following:

#! /u1/Php/php/bin/php -q

echo $a;
echo "hello";
$b=`msmtp < /u2/ftp/mail.txt &`;
echo $b;

This code works.

Thanks bathory.

All times are GMT -5. The time now is 01:33 PM.