I want to run the sendmail command on Linux in the virtual environment and send a test email to Gmail.

Asked 2 months ago, Updated 2 months ago, 7 views

When you run the sendmail command on Linux in a virtual environment, the following message appears:

can't connect to remote host 127.00.1 Connection refused

Can I use the sendmail command to send mail from my computer's virtual environment to accounts such as Gmail?

execution commands:

Run Environment:

·Set bridge adapter + host only adapter in VirtualBox
·Pings pass to other terminals connected to the same network (wireless LAN at home)
·I can't ping the host OS

That's all.I would appreciate it if you could provide me with information.

linux virtualbox sendmail

2022-09-30 11:19

1 Answers

Describes how to send mail to Gmail by introducing the mail command + postfix.

Here's how to send an email using the Centos 7.9+postfix+mail command

 // Insert postfix
# yum install postfix Cyrus-sasl-plain

// Add whole settings below (add + part)
# vim/etc/postfix/main.cf

+ relayhost=smtp.gmail.com:587
+ # SASL Authentication
+ smtp_sasl_auth_enable=yes
+ smtp_sasl_password_maps=hash:/etc/postfix/gmail_passwd
+ smtp_sasl_security_options = noanonymous
+ smtp_sasl_mechanism_filter=plain
+ # TLS Settings
+ smtp_use_tls=yes
+ smtp_tls_security_level=encrypt
+ tls_random_source=dev:/dev/urandom

Create a file in /etc/postfix/gmail_passwd

smtp.gmail.com:587 account ト@gmail.com:passwords

Apply and delete files with passwords, restart postfix

# rm-f/etc/postfix/gmail_passwd
# systemctl start postfix 
# systemctl status postfix 

Send Mail

#echo "Body" | mail-s "Title" -r [email protected] [email protected]

Please refer to the following

2022-09-30 11:19

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.