Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9160053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:38:39+00:00 2026-06-17T13:38:39+00:00

I wrote script to send mail automatically using an SMTP connection but when I

  • 0

I wrote script to send mail automatically using an SMTP connection but when I execute the script, sometimes it works and sometimes it is not sending mail. Behavior is quite ambiguous.

Environment : Linux Server Fedora 14 
Mailing Client : Lotus Notes 8.5.2

Please find script below.

# Function for sending email
sendemail(){
date=`date '+%d-%m-%Y'`
dbDir=/var/lib/MYSQLBACKUP/$date
dbname='DBNAME'
log_file="${dbDir}/${dbname}_${date}.log"
attached_file="${dbname}_${date}.log"
echo $log_file
echo $attached_file
encoded_log_file=`cat $log_file | openssl base64`
#echo $encoded_log_file
( echo open 172.40.201.31 25
sleep 8
echo helo 172.40.201.31
echo mail from:Pratik.Vyas@gmail.com
echo rcpt to:Pratik.Vyas@gmail.com
echo data
echo to:Pratik.Vyas@gmail.com
echo from:Pratik.Vyas@gmail.com
echo "subject: SPARC CQ DB Backup Report : $date :"
echo "MIME-Version: 1.0"
#echo "Content-Type: text/plain; charset=UTF-8"
#echo "Please view attached file"
echo "Content-Type: text/x-log;name="$attached_file""
echo "Content-Disposition:attachment;filename="$attached_file""
echo "Content-Transfer-Encoding: base64"
echo $encoded_log_file
echo $1
sleep 15
echo .
echo ^]
echo quit ) | telnet
echo "status:$?"
echo "Hello done"
}

sendemail
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:38:40+00:00Added an answer on June 17, 2026 at 1:38 pm

    Here’s a rewrite using /usr/lib/sendmail. This is not necessarily the correct location for your system, but you should be able to adapt it.

    # Function for sending email
    sendemail(){
        date=$(date '+%d-%m-%Y')                        # prefer $(...) over `...`
        dbDir=/var/lib/MYSQLBACKUP/$date
        dbname='DBNAME'
        log_file="${dbDir}/${dbname}_${date}.log"
        attached_file="${dbname}_${date}.log"
        echo $log_file
        echo $attached_file
        encoded_log_file=$(openssl base64 < "$log_file")  # notice UUCA fix + quoting
        #echo $encoded_log_file
        # You should configure sendmail to use 172.40.201.31 as your smarthost
        /usr/lib/sendmail -oi -t <<________HERE
    to: Pratik.Vyas@gmail.com
    from: Pratik.Vyas@gmail.com
    subject: SPARC CQ DB Backup Report : $date :
    MIME-Version: 1.0
    Content-Type: text/x-log; name="$attached_file"
    Content-Disposition: attachment; filename="$attached_file"
    Content-Transfer-Encoding: base64
    X-Ample: notice empty line between headers and body!    # <-- look
    
    $encoded_log_file
    $1
    ________HERE
        echo "status:$?"
        echo "Hello done"
    }
    
    sendemail
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wanna write a script sending e-mail to my client automatically using php How
If I want to send mail not via SMTP, but rather via sendmail, is
I wrote a PHP script for sending email. I am using a CMS which
I am trying to send mail using PHP but it doesn't seem to be
The following script sends email using mail function . But i am unable to
I wrote a script parsing a .csv file in groovy using tokenize, which ended
I wrote this script to for a contact form on my website, everything works
i have wrote a script to produce an array of data but now want
I have to write a script to send mails using unix shell scripts. The
I wrote a script to send the contents of a contact form (first name,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.