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 02-19-2013, 06:19 PM   #1
Batistuta_g_2000
Member
 
Registered: Oct 2011
Posts: 85
Blog Entries: 1

Rep: Reputation: Disabled
Using sendEmail inside a bash script.


Code:
#!/bin/bash
emailsend=larrythelegend@gmail.com
emailrec=larrythelegend@yahoo.co.uk
password=larry12345
name=larry

sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u  EMAIL WILL GO THIS TIME -m OH YEAH -a error.txt
Does not work in script but in terminal I can do:
emailsend=larrythelegend@gmail.com
emailrec=larrythelegend@yahoo.co.uk
password=larry12345
name=larry

Then run:

sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u EMAIL WILL GO THIS TIME -m OH YEAH -a error.txt
....................................................

when I run script above I get Error:

Feb 19 11:19:41 ubuntu sendEmail[13201]: DEBUG => SMTP-AUTH: Using PLAIN authentication method
Feb 19 11:19:41 ubuntu sendEmail[13201]: INFO => Sending: AUTH PLAIN Um9zcwBSb3NzAEJhdGlzdHV0YTY2Ng==
Feb 19 11:19:41 ubuntu sendEmail[13201]: ERROR => Received: 535-5.7.1 Username and Password not accepted. Learn more at, 535 5.7.1 http://support.google.com/mail/bin/a...y?answer=14257 fv2sm27612749wib.6 - gsmtp

___________________________________________________

Have tried using mutt but too much install issues - sendemail works good from commandline just not in script is it a subshell issue?
 
Old 02-19-2013, 08:07 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
What OS?
 
Old 02-19-2013, 08:13 PM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
have you checked this out ?
Feb 19 11:19:41 ubuntu sendEmail[13201]: ERROR => Received: 535-5.7.1 Username and Password not accepted.
 
Old 02-19-2013, 08:39 PM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
How did you write your script? Maybe there are hidden windows carriage returns in there that are being passed into the command.
 
Old 02-19-2013, 09:17 PM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
If you purpose is just to send an email, you could have tried other mail agents like mailx (see here), mail or sendmail etc.
Code:
~$ mailx -s "<subject" "larrythelegend@yahoo.co.uk" < error.txt
 
Old 02-20-2013, 05:33 AM   #6
Batistuta_g_2000
Member
 
Registered: Oct 2011
Posts: 85

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by shivaa View Post
If you purpose is just to send an email, you could have tried other mail agents like mailx (see here), mail or sendmail etc.
Code:
~$ mailx -s "<subject" "larrythelegend@yahoo.co.uk" < error.txt
Sorry - using ubuntu 12 - bash script from terminal - no email (or any other apps installed).

Yes essentially I want to write a script which installs sendEmail application and sends an email (tried mutt but kept getting all kinds of "unable to attach" errors) so came across: http://ubuntuforums.org/showthread.php?t=1268015
and sendEmail, installed all packages and was finally able to send an email, but when i put this sendEmail code in script it returned an authenticate error message, just wondering why is it a scope issue?


Code:
#!/bin/bash
          #### INSTALL ALL SENDEMAIL PACKAGES ETC...###############
     sudo apt-get install logwatch
     wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
     tar zxvf sendEmail-v1.55.tar.gz
     sudo cp sendEmail-v1.55/sendEmail /usr/local/bin
     sudo chmod +x /usr/local/bin/sendEmail
     sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl perl
         #### Emter user info ###########
     emailsend=XXXXX@gmail.com
     emailrec=XXXXXX@yahoo.co.uk
     password=XXXXXXX
     name=XXXXX
       ###### Send Email ###############
sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u  -m Oh Yeah Fuck it -a error.txt
Error:

Feb 20 03:23:57 ubuntu sendEmail[13646]: INFO => Sending: AUTH PLAIN Um9zcwBSb3NzAEJhdGlzdHV0YTY2Ng==
Feb 20 03:23:57 ubuntu sendEmail[13646]: ERROR => Received: 535-5.7.1 Username and Password not accepted. Learn more at, 535 5.7.1 http://support.google.com/mail/bin/a...y?answer=14257 bg5sm33221910wib.8

Checked all above in google help.html above, no joy

sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u TEST HEADER -m "logfor/$day" -a ~/error.txt


********************************************************************************

Email script alone will not work...have a go anyone?

Code:
#!/bin/bash
touch error.txt
day=$(date +"%T-%m-%d-%Y")
echo "Enter your email address"
read emailsend
echo "Enter your email password"
read password
echo "Enter recipient email address"
read emailrec
echo "Enter your first name"
read name
clear
echo "Sender is $emailsend"
echo "Password is $password"
echo "Recipient is $emailrec"
echo "Username is $name"
echo "logfor/$day"
sleep 8s
clear
sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u TESTHEADER -m "logfor/$day" -a ~/error.txt
 
Old 02-20-2013, 05:45 AM   #7
Batistuta_g_2000
Member
 
Registered: Oct 2011
Posts: 85

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by Batistuta_g_2000 View Post
Sorry - using ubuntu 12 - bash script from terminal - no email (or any other apps installed).

Yes essentially I want to write a script which installs sendEmail application and sends an email (tried mutt but kept getting all kinds of "unable to attach" errors) so came across: http://ubuntuforums.org/showthread.php?t=1268015
and sendEmail, installed all packages and was finally able to send an email, but when i put this sendEmail code in script it returned an authenticate error message, just wondering why is it a scope issue?


Code:
#!/bin/bash
          #### INSTALL ALL SENDEMAIL PACKAGES ETC...###############
     sudo apt-get install logwatch
     wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
     tar zxvf sendEmail-v1.55.tar.gz
     sudo cp sendEmail-v1.55/sendEmail /usr/local/bin
     sudo chmod +x /usr/local/bin/sendEmail
     sudo apt-get install libio-socket-ssl-perl libnet-ssleay-perl perl
         #### Emter user info ###########
     emailsend=XXXXX@gmail.com
     emailrec=XXXXXX@yahoo.co.uk
     password=XXXXXXX
     name=XXXXX
       ###### Send Email ###############
sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u  -m Oh Yeah Fuck it -a error.txt
Error:

Feb 20 03:23:57 ubuntu sendEmail[13646]: INFO => Sending: AUTH PLAIN Um9zcwBSb3NzAEJhdGlzdHV0YTY2Ng==
Feb 20 03:23:57 ubuntu sendEmail[13646]: ERROR => Received: 535-5.7.1 Username and Password not accepted. Learn more at, 535 5.7.1 http://support.google.com/mail/bin/a...y?answer=14257 bg5sm33221910wib.8

Checked all above in google help.html above, no joy

sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u TEST HEADER -m "logfor/$day" -a ~/error.txt


********************************************************************************

Email script alone will not work...have a go anyone?

Code:
#!/bin/bash
touch error.txt
day=$(date +"%T-%m-%d-%Y")
echo "Enter your email address"
read emailsend
echo "Enter your email password"
read password
echo "Enter recipient email address"
read emailrec
echo "Enter your first name"
read name
clear
echo "Sender is $emailsend"
echo "Password is $password"
echo "Recipient is $emailrec"
echo "Username is $name"
echo "logfor/$day"
sleep 8s
clear
sendEmail -v -f "$emailsend" -s smtp.gmail.com -xu "$name" -xp "$password" -t "$emailrec" -o tls=yes -u TESTHEADER -m "logfor/$day" -a ~/error.txt

MY MISTAKE ......Grrrr...was a username problem - needed proper "username" for smtp.gmail.com - i didnt realise!!!

Thanks all.
 
Old 02-20-2013, 07:30 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
so, was it name=XXXXX or name=XXXXX@gmail.com for the field?
 
  


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
sendEmail: Script and Array Kashif_Bash Programming 3 04-22-2012 03:33 AM
[SOLVED] ls command inside bash script error sopier Programming 11 12-17-2011 10:19 PM
[SOLVED] Using bash shell script inside php lakshman.1043 Linux - Newbie 2 12-30-2010 01:41 AM
Bash Script Help - Trying to create a variable inside script when run. webaccounts Linux - Newbie 1 06-09-2008 02:40 PM
Execute bash script inside PHP creatorrr Programming 11 11-21-2007 04:32 PM

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

All times are GMT -5. The time now is 10:09 AM.

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