Use SMTP proxy to send emails in Linux

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.