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

0 votes
Oct 5, 2020 in Linux Administration by Shashi
• 360 points
76 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, 2020 by MD
• 95,060 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,640 points
4,907 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, 2020 in Linux Administration by akhtar
• 38,170 points
155 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, 2020 in Linux Administration by MD
• 95,060 points
252 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, 2020 in Linux Administration by MD
• 95,060 points
63 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
6,606 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,090 points
570 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,090 points
201 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,090 points
219 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, 2020 in Linux Administration by MD
• 95,060 points
140 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, 2020 in Linux Administration by MD
• 95,060 points
98 views