Creating a function that sends a mail using mail command

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Creating a function that sends a mail using mail command
# 1  
Old 12-07-2013
Creating a function that sends a mail using mail command

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

The function will be called m and it will allow you to send an email to someone using the mail command. The function should take the To: address, a Cc: address using the –t parameter, a subject line using the –s parameter and an input file. When running this function, you will type something like the following as an example:

m email1 email2 subject someinputfile.

2. Relevant commands, code, scripts, algorithms:

m email1 email2 subject someinputfile
-t, -s

3. The attempts at a solution (include all code and scripts):
Code:
m()  
{  
mail=$1  
-t=$2  
-t=$3  
-s=$4  
<=$5  
}

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Chemeketa Community College, Salem, Oregon, USA, D. Kraus, CIS140U (Cannot link yet)

Last edited by Drucian; 12-07-2013 at 02:54 AM..
# 2  
Old 12-07-2013
The problem description is a bit confusing.
I think the following interpretation makes sense: the function m takes 4 parameters, and runs mail, passing parameters as arguments with additional -s and -t arguments, as required by mail.
Your current function assigns variables but does not run the mail command.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies

2. UNIX for Advanced & Expert Users

Unable to send mail with 'mail' command

I am unable to cause the 'mail' command to send mail from my linux ubuntu 15.10 computer. File 'mail.log' typically reports Connection timed out. I issue the command: mail -s "my subject" recipient@domain.com < filenamewhere filename is a file containing my message. Specifically, the... (3 Replies)
Discussion started by: tcnm
3 Replies

3. Shell Programming and Scripting

How to send mail using PHP mail function On apache server.?

Hello, I am using centos-6.2 I have apache server,php5 on my system and I want to send mail using sendmail on my system. when I try to send mail from shell that time mail is succesfully sent to respective address() but when I try to send it through webbrowser I am not able to send it.... (1 Reply)
Discussion started by: Kiran ursal
1 Replies

4. Shell Programming and Scripting

Not able to send the mail using mail and mailx command

Hi All, I am trying to send a mail from linux server but could'nt able to send the mail. I tried the below syntax's so far but no luck. mail -s “Hello world” abc@xyz.com < /usr/g/txt.log cat "txt.log" | mailx -s "Hello world" abc@xyz.com mailx -s “Hello world” abc@xyz.com <... (2 Replies)
Discussion started by: scriptscript
2 Replies

5. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

6. Solaris

identify the mail server for mail command

Hi , I am new to unix , i am using the mail and mailx command to send the mail .How come i will know the my mail command using which server as mail box.. Please help me .. Thanks in advance (1 Reply)
Discussion started by: julirani
1 Replies

7. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

8. Solaris

how to forward mail in /var/mail/username to external mail

Dear All, Now I use solaris 10 and I try to forward mail from /var/mail/username to their external mail so what should I do? thank u in advance (2 Replies)
Discussion started by: unitipon
2 Replies

9. Shell Programming and Scripting

PHP Script that sends mail - Postfix breaks it

I have a PHP Script that works perfectly on a server that uses Sendmail. However I tried to port it to a new server that has the Postfix to Sendmail compatibility interface, and it doesn't work properly. The php.ini file has the path for sendmail on both servers set to: /usr/sbin/sendmail -t... (0 Replies)
Discussion started by: boopfm523
0 Replies

10. UNIX for Dummies Questions & Answers

Cron Sends mail to root on completion of job.

All I am running a few scripts through a cron job. This is for checking some key services that are running on by box. The problem is, everytime the cron runs, it sends a mail to the root account. The root account mails need to cleared every now and then. Is there some way I can stop these... (1 Reply)
Discussion started by: skotapal
1 Replies
Login or Register to Ask a Question