LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-07-2011, 09:08 AM   #1
gmail_cs
LQ Newbie
 
Registered: Feb 2011
Distribution: Hard working
Posts: 4

Rep: Reputation: 0
php cannot invoke msmtp


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


Thank you.
This is a test mail.
---------------------
Please pay attention to the two null lines.
I hope some answers.Thank you.
 
Old 03-08-2011, 03:31 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi and welcome to LQ,

Does msmtp works when invoked from CLI, like:
Code:
msmtp niubl967@gmail.com < /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

Regards
 
1 members found this post helpful.
Old 03-08-2011, 08:50 AM   #3
gmail_cs
LQ Newbie
 
Registered: Feb 2011
Distribution: Hard working
Posts: 4

Original Poster
Rep: Reputation: 0
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
defaults
tls on
tls_trust_file /etc/pki/tls/certs/ca-bundle.crt
logfile ~/Mail/msmtplog

# Gmail service
account gmail
host smtp.gmail.com
from niubl967@gmail.com
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.
 
Old 03-08-2011, 11:17 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

Quote:
#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.

Regards
 
1 members found this post helpful.
Old 03-09-2011, 12:46 AM   #5
gmail_cs
LQ Newbie
 
Registered: Feb 2011
Distribution: Hard working
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
Old 03-09-2011, 01:54 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

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

Regards
 
Old 03-10-2011, 07:41 PM   #7
gmail_cs
LQ Newbie
 
Registered: Feb 2011
Distribution: Hard working
Posts: 4

Original Poster
Rep: Reputation: 0
I can send a mail from CLI.A test code is following:

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

<?php
$a=`ls`;
echo $a;
echo "hello";
$b=`msmtp 353923279@qq.com < /u2/ftp/mail.txt &`;
echo $b;
?>

This code works.

Thanks bathory.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Using msmtp as a Lightweight SMTP Client LXer Syndicated Linux News 0 02-08-2011 10:21 PM
Msmtp on CentOS 5.2 : cannot send mail jonaskellens Linux - Newbie 2 07-10-2009 04:44 AM
user crontab and msmtp packages not working together ? frenchn00b Linux - Server 1 04-20-2009 10:10 AM
mutt and msmtp not emailing mahmoud Linux - Software 2 12-29-2008 08:29 AM
Msmtp+Mutt password prompt pete1234 Linux - General 0 07-17-2006 10:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration