celtician
asked on
Finding out if "mail" function is availabe
How do i know if the "mail" funcion in unix is avialbe in some directory??
I have some script in a machine using mail function, when i execute it in machine1 i get the mail sent
however when i execute the same script in machine2 i dont get any error, however no mail is being sent....
how can i know if the mail function is actually enable or availabe in that machine/location???
I have some script in a machine using mail function, when i execute it in machine1 i get the mail sent
however when i execute the same script in machine2 i dont get any error, however no mail is being sent....
how can i know if the mail function is actually enable or availabe in that machine/location???
which mail
ASKER
I get this when executing that:
machine:username:/home/use rname/data $ which mail
/usr/bin/mail
machine:username:/home/use
/usr/bin/mail
Then the "mail" function is available in /usr/bin
ASKER
so, if i want to execute it from another location such as /usr/data/myscript.ksh, what do i need to do? do i need to declare it somehow in the script??
If the script on machine1 is sending thru a user that exists on machine1, the same user may not exist on machine2. You may have to change the user that is sending the email on machine2.
ASKER
in this case i would like to send directly from machine2, not making the call from machine1
Can you post your script that sends the email, at least that part of the script? You can hide or obscure the email address you are using.
ASKER
sure, it works perfectly on machine1, but not on machine2
#!/bin/ksh
MAIL_FILE="testfile.txt"
rm -f $MAIL_FILE
echo "From:ScriptTesol" > $MAIL_FILE
echo "To:Me LastName <mail@mycompany.com>" >> $MAIL_FILE
echo "Subject:Test eMail" >> $MAIL_FILE
echo "Content-Type: text/html" >> $MAIL_FILE
echo "<html>" >> $MAIL_FILE
echo "<body style='font-family:calibri ;font-size :14px;'>" >> $MAIL_FILE
echo "<h2> Test email h2 </h2>" >> $MAIL_FILE
cat $MAIL_FILE|mail me@mycompany.com
#!/bin/ksh
MAIL_FILE="testfile.txt"
rm -f $MAIL_FILE
echo "From:ScriptTesol" > $MAIL_FILE
echo "To:Me LastName <mail@mycompany.com>" >> $MAIL_FILE
echo "Subject:Test eMail" >> $MAIL_FILE
echo "Content-Type: text/html" >> $MAIL_FILE
echo "<html>" >> $MAIL_FILE
echo "<body style='font-family:calibri
echo "<h2> Test email h2 </h2>" >> $MAIL_FILE
cat $MAIL_FILE|mail me@mycompany.com
does
mail -v me@mycompany.com
report anything?
mail -v me@mycompany.com
report anything?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Whe doing mail -v me@mycompany.com i get:
mail: illegal option -- v
mail: Usage: [-ehpPqr] [-f file] [-x debuglevel]
or [-tw] [-m message_type] [-T file] [-x debuglevel] persons
or [-x debuglevel]
mail: illegal option -- v
mail: Usage: [-ehpPqr] [-f file] [-x debuglevel]
or [-tw] [-m message_type] [-T file] [-x debuglevel] persons
or [-x debuglevel]
I don't see me@mycompany.com as one of the options
what does
man mail
say?
what does
man mail
say?
ASKER
In the funcion above the mail is being sent using that function and being set as parameter as its written.
I substituted 'sendmail' for 'mail'. Your script works perfectly sending to one email address and not at all sending to another one. The mail server you are sending to or thru may make a difference also.