# Use Sendmail to auto send daily email



## javajo91 (Nov 9, 2011)

Good morning - 

I've built a FreeBSD box so i can learn UNIX.  I currently administer a Windows environment and need to send out a daily email every morning to one email address.  The email never changes.  I realize there a probably a dozen ways to accomplish this in Windows but i would love to perform the task using Sendmail and automate it with Cron.  I'm using it as an opportunity to learn something new..

Any help would be much appreciated.

Thank you!


----------



## wblock@ (Nov 9, 2011)

If the message is always the same, why send it?

Anyway, see mail(1).  Write a small script to send the message.  Then add it as a cron job.


----------



## javajo91 (Nov 9, 2011)

wblock - I agree...its more of checking on status of a remote office to remind them to alert us to any issues.

Being that i am new to Perl, Sendmail and Cron I was wondering if i could get some guidance.. perhaps a pre-existing post that you could point me to. I've looked through the individual MAN pages for each but am a bit confused as to how to tie them all together...
I can prob get the script together but am a bit grey on tying it to Cron..although from what I've initially seen looks rather painless..

thanks again!!


----------



## wblock@ (Nov 9, 2011)

Okay, step 1: send an email from the command line.

mail(1) does this.  It takes stdin as the message body and -s specifies the subject.  The last parameter is the address.  For example:
`% echo "This is a short test message." | mail -s "Short Test" [email]exampleuser@example.com[/email]`

Try that.  It will try to connect directly to the machine called example.com.  If that's not inside your internal network, or can't directly receive SMTP mail, then the Sendmail configuration will have to be changed.


----------



## javajo91 (Nov 9, 2011)

Thank u so much wblock - I appreciate you taking the time to help!


----------



## javajo91 (Nov 10, 2011)

Good morning wblock@ - quick question.  I have my simple cron job scheduled and running a simple shell mail command.  Is there a way to create an alias so when my users receive the email instead of them seeing from Charlie Root they see my_email@mydomain.com  My FreeBSD box is outside my LAN...
the domain on the FreeBSD box is not registered yet and i don't want to run into the issue of them replying to the email only to have it bounce back to them as unrecoverable..

From the skimming ive done it looks like the inferent security built into FreeBSD is limiting Cron to root?


Thanks again!!


----------



## SirDice (Nov 10, 2011)

javajo91 said:
			
		

> Good morning wblock@ - quick question.  I have my simple cron job scheduled and running a simple shell mail command.  Is there a way to create an alias so when my users receive the email instead of them seeing from Charlie Root they see my_email@mydomain.com  My FreeBSD box is outside my LAN...
> the domain on the FreeBSD box is not registered yet and i don't want to run into the issue of them replying to the email only to have it bounce back to them as unrecoverable..


You will have to configure sendmail to handle this.



> From the skimming ive done it looks like the inferent security built into FreeBSD is limiting Cron to root?


No, but there's a difference between /etc/crontab and crontab(1).

Don't edit the file, it should only be used for system processes. Use crontab -e as a normal user. Keep in mind that the syntax is exactly the same as for the system's /etc/crontab _except_ you don't enter a username.


----------



## javajo91 (Nov 16, 2011)

Thank you!  All squared away - Apologies for the late response.


----------

