Use SMTP proxy to send emails in Linux
If you want to send emails under Linux without an independent domain name host, you cannot send emails to the outside.
Therefore, we can solve this problem with a single issue. In short, we use Linux as a mailbox client to log on to an existing mailbox, such as 126,163, use a login email to send an email to the Internet.
Test environment:
# Uname-
Linux 2.6.32-358. el6.x86 _ 64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Method 1:
Yum install-y mailx
It mainly modifies the/etc/mail. rc file.
Edit the/etc/mail. rc file and add the following content:
Set from = Account of the User@XX.com login mailbox, such as bkjia@126.com
Set smtp = smtp server of smtp.XXX.com mailbox, such as smtp.126.com
Set smtp-auth-user = the user Name of the User@XX.com mailbox, such as the bkjia@126.com
Set smtp-auth-password = Password password of the email
Set smtp-auth = login authentication method: login
Disable system sendmail and postfix
# Service sendmail stop
# Service postfix stop
# Chkconfig sendmail off
# Chkconfig postfix off
Send test email:
Echo "hello" | mail-s "Title" bkjia@126.com
Depending on the network speed, carrier, or SMTP, mail sending will be delayed.
Method 2: Use mutt and msmtp proxy to send emails
Yum-y install mutt msmtp
Edit/etc/Murrtc and add the following code:
Absolute path of the set sendmail = "/usr/bin/msmtp" msmtp command
Set use_from = yes
Set realname = "Test" Custom display sender
Set from = "bkjia@126.com" mailing address
Set envelope_from = yes
Edit/root/. msmtprc and add the following code:
Account default
Smtp address of the mailbox used by host smtp.126.com
From bkjia@126.com hair address
Auth login, modified according to the authentication method supported by smtp
User bkjia email account, excluding the domain name after @
Password bkjia password
Logfile/var/log/msmtp. log file path
Service postfix restart
Echo 'this is a test mail' | mutt-s 'test'-a/tmp/test.txt wantyi@126.com
This article permanently updates the link address: