参考网站
https://easyengine.io/tutorials/mail/dkim-postfix-ubuntu/
http://www.elandsys.com/resources/mail/dkim/opendkim.html
Install DKIM
apt-get install opendkim opendkim-tools
Edit Config files
DKIM config
Open dkim config file vim /etc/opendkim.conf
Add following lines towards end. Make sure you replace example.com with your domain/subdomain.
Domain example.com
KeyFile /etc/postfix/dkim.key
Selector mail
SOCKET inet:8891@localhost
Next open dkim defaults file vim /etc/default/opendkim
Change default socket path by adding a line like below:
SOCKET="inet:8891@localhost"
Postfix file
Open postfix main config file vim /etc/postfix/main.cf
Add following lines towards end.
# DKIM
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
Generating a public and private key
DKIM requires a public and private key. The private key should be saved in a safe location on your server. The public key will used in the DNS TXT record for DKIM.
Enter the following command to generate your private key:
openssl genrsa -out rsa.private 1024
Enter the following command to generate your public key:
openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM
Move your private key to the dkim directory and rename it to mail.key.pem using the following command:
mv rsa.private /var/db/dkim/mail.key.pem
mail is the selector name in our example.
DNS TXT record for DKIM
Create a DNS TXT record for selector._domainkey.example.com as follows:
mail._domainkey.example.com. IN TXT "v=DKIM1; k=rsa; p=MEwwPQRJKoZIhvcNADAQCQADOwAwOAIxANPpYHdE2tevfEpvL1Tk2dDYv0pF28/f5MxU83x/0b sn4R4p7waPaz1IbOGs/6bm5QIDAQAB"
The string after p= is the base64 encoding of your public key.
If the rsa.public file which was generated contains
-----BEGIN PUBLIC KEY-----
MEwwPQRJKoZIhvcNADAQCQADOwAwOAIxANPpYHdE2tevfEpvL1Tk2dDYv0pF28/f 5MxU83x/0bsn4R4p7waPaz1IbOGs/6bm5QIDAQAB
-----END PUBLIC KEY-----
the base64 encoding is everything between the first ----- BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- lines. You should remove any spaces and newlines.
2015年12月20日星期日
2015年10月17日星期六
2015年7月26日星期日
重置xen虚拟机的密码。
找到虚拟机的文件
类似disk = ["phy:/dev/vg0/test-disk,sda1,w"]
mount -o loop /dev/vg0/test-disk /mnt
chroot /mnt
mount -o remount,rw /
passwd
mount -o remount,ro /
exit
umount /mnt
2015年7月2日星期四
Send Gmail from the Linux Command Line(ubuntu下通过命令行发送GMAIL)
Install msmtp
The first step is to install the msmtp-mta package.
sudo apt-get install msmtp-mta
After the install is complete you'll need to set up the defaults file with your Gmail account information. You need to create a file in your home directory called .msmtprc.
nano ~/.msmtprc
Paste the following into the file and edit the portions in bold to reflect your account information.
#Gmail account
defaults
logfile ~/msmtp.log
account gmail
auth on
host smtp.gmail.com
from your_address@gmail.com
auth on
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
user your_address@gmail.com
password your_gmail_password
port 587
auth on
host smtp.gmail.com
from your_address@gmail.com
auth on
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
user your_address@gmail.com
password your_gmail_password
port 587
account default : gmail
Save the file and exit the text editor. Since this file contains your account credentials, you'll want to change the permissions to make the file readable only by you.
chmod 600 .msmtprc
Install mailx
Now that your computer is configured to talk to Gmail, you need a command line email program to handle writing your email. For this I'm going to use mailx from the heirloom-mailx package.
sudo apt-get install heirloom-mailx
Now you need to set up the defaults file so that mailx uses msmtp to send out the email. This file is called .mailrc.
nano ~/.mailrc
Now paste the following into the file and save it.
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
set message-sendmail-extra-arguments="-a gmail"
You should now be able to send email from your terminal command line.
Sending email from the command line
Now you can send email from the command line like this:
mail -s "Subject" address@example.com
The cursor will go to a blank line. Enter your email message. When you're done, hit <Enter> to go to a blank line and then hit <Ctrl>+D to end your message. You have just sent your email.
Here you can see that I've sent an email to myself from my Gmail account.
You can also use a message saved in a text file rather than entering it interactively. This is especially useful if you're automating this process in a script. In this example, the email is saved in a file called message.txt.
mail -s "Subject" address@example.com < message.txt
This content originally appeared at http://tuxtweaks.com/2012/10/send-gmail-from-the-linux-command-line/.
订阅:
评论 (Atom)