How to configure Gmail in centos7 to send notifications to specific email id's ?

0 votes
Oct 5 in Linux Administration by Shashi
• 360 points
46 views

1 answer to this question.

0 votes

Hi@Shashl,

You can use python script in your CentOS system to set email notification. You can use the SMTP module in your script.

# send mail
import smtplib,getpass
sender='abc@gmail.com'
receiver=['xyz@gmail.com','zzz@gmail.com']
password='xxxxx'
smtpserver=smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(sender,password)
msg='Subject:Demo\nThis is a demo'
smtpserver.sendmail(sender,receiver,msg)
print('Sent')
smtpserver.close()
answered Oct 5 by MD
• 79,930 points
I want to trigger email notification through shell script.

For example : If I am running the script to get version of an application like java, docker, jenkins then script has to trigger an email to mentioned mail id's with the versions.

Hi@shashl,

You can do that. Create a simple shell script that will call the python script. So whenever you will run the shell script, it will run the required command and send an email.

Related Questions In Linux Administration

0 votes
1 answer

How to Unblock SSH and FTP Access to Specific IP in Linux?

Firewalls(most of them) can either Reject or ...READ MORE

answered Jul 16, 2019 in Linux Administration by Archana
• 5,600 points
3,877 views
0 votes
1 answer

How to configure SSH server in RHEL/CentOS?

Hi@MD, To configure SSH server to your system, ...READ MORE

answered Mar 30 in Linux Administration by akhtar
• 33,720 points
122 views
0 votes
1 answer

How to configure yum in RedHat system?

Hi@akhtar, By default, RedHat has one ISO file. ...READ MORE

answered Jul 27 in Linux Administration by MD
• 79,930 points
163 views
0 votes
1 answer

How to capture Packets from Specific Interface in Linux?

Hi@akhtar, You can use tcpdump command in your ...READ MORE

answered Oct 3 in Linux Administration by MD
• 79,930 points
32 views
0 votes
1 answer

How to increase Swap Memory in CentOS 7?

Follow the below steps and procedures: Prerequisites Must have ...READ MORE

answered Oct 5, 2018 in Linux Administration by Frankie
• 9,810 points
5,861 views
–1 vote
1 answer

How to get octal file permission in linux?

You can use this: stat -c "%a %n" ...READ MORE

answered Jan 3, 2019 in Linux Administration by Omkar
• 69,030 points
491 views
0 votes
1 answer

How to take input from user in bash script?

You can use if-else branch to check ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,030 points
153 views
0 votes
1 answer

How to create a symlink in Linux?

To create a symbolic link, you can ...READ MORE

answered Jan 31, 2019 in Linux Administration by Omkar
• 69,030 points
188 views
+1 vote
1 answer

How to configure NFS server in Linux?

Hi@akhtar, To configure NFS server in your system, ...READ MORE

answered May 27 in Linux Administration by MD
• 79,930 points
120 views
0 votes
1 answer

How to configure FTP server in Linux System?

Hi@akhtar, You need to install vsftpd software in ...READ MORE

answered Jul 9 in Linux Administration by MD
• 79,930 points
77 views