Changes

From Amahi Wiki
Jump to: navigation, search
no edit summary
{{MessageBox|backgroundcolor =#faa|image =Warning.png|heading = Send WARNING|message = This is recommended only for advanced users, proceed with caution.}}This tutorial is now available as the Amahi [https://www.amahi.org/apps/postfix-mail through your HDA using your gmail account ===-relay Post Mail Relay] application.
tags: mail gmail f14 postfix relayThis can be used to send mails from your Amahi 7 or greater (Fedora 19 or greater) HDA and to receive system emails. To receive emails meant for the root user, you have to [[Forward_System_Emails|Forward System Emails]] after finishing this tutorial. You also might want to take a look at [[Masquerade_email_address|Masquerade email address]] as well.<br>
WarningREF: Only try this if you know what you’re doing.<br><br>I took the information from [this page [http://carlton.orileyopentodo.net/blog2013/?p=31]] and modified them slightly for Fedora 14 03/ Amahi 6postfix-smtp-relay-to-smtp-gmail-com Postfix SMTP relay to SMTP gmail. <br><br>com]
* First of all, install postfix and remove sendmail: <br><pre>yum -y install postfix mailxyum -y remove sendmail</pre>
{{Code|yum -y install * Add the following to the bottom of the file /etc/postfix/main.cf. You do not need to change anything else in it, as the last setting for any option is the one that is saved.yum -y remove sendmail}}Openssl and openssl-perl are needed to generate certificates and create SSL connections to GMail<brpre>####Gmail SMTP RelayOpenssl should be installed already, but to be sure#TLS parameterssmtpd_use_tls=yessmtpd_tls_session_cache_database = btree: <br>${data_directory}/smtpd_scachesmtp_tls_session_cache_database = btree:${{Code|yum -y install openssl openssl-perl}data_directory}/smtp_scachesmtp_tls_note_starttls_offer = yessmtp_tls_policy_maps = hash:/etc/postfix/tls_policy #Relay host configurationA Certificate Authority is needed to create the necessary certificatesrelayhost = [smtp.gmail. You can skip the next paragraph if you already have onecom]:587 #SASL Configurationsmtp_sasl_auth_enable = yessmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_sasl_security_options = noanonymoussmtp_sasl_mechanism_filter = plainsmtp_sasl_tls_security_options = noanonymous</pre><br/>
{{Code|cd * Create /etc/pkipostfix/tlssasl_passwd file with your Gmail login credentials that looks like below:<pre>[smtp.gmail.com]:587 user@gmail.com:Password</pre><br /misc><b>NOTE:</b> Change ''user'' to your username and ''password'' to your gmail crredentials.<br /CA.pl –newca}}>
*You will be prompted for Build the file name, hit enter to create a new CA.* You will need to enter a passphrase next, be sure to remember it.*Choose the Country Name, State or Province Name, Locality Name, Organization Name, and Organizational Unit Name to your liking. Be sure to remember the values, they will be needed in the key creation later. *For the Common Name, type “CA” (without quotes). *Take defaults for everything else and when prompted enter the passphrase from above.password database: <br>Now a key that is sent to GMail to start the SSL encryption will be created<pre>postmap hash: /etc/postfix/sasl_passwd<br/pre>
{{Code|cd * Create /etc/pkipostfix/tlstls_policy file that looks like below:mkdir gmail_relaycd gmail_relayopenssl genrsa -out server<pre>[smtp.key 1024openssl req -new -key servergmail.key -out server.csr}}com]:587 encrypt</pre>You will be prompted for country etc. like when creating the CA. Enter the same values. <br/>As Common Name, now enter * Build the name of your server, FQDN or not, your choice. policy database: <br>{{Code|openssl ca -out server.pem -infiles server.csr}}You will need to enter your passphrase again at this point.<brpre>postmap /etc/postfix/tls_policy</pre>When asked if you want to sign the key, answer yes, same when asked if to commit it.
Add * Protect the following to the bottom of the file files with your Gmail login data:<pre>chmod 600 /etc/postfix/main.cf. You do not need to change anything else in it, as the last setting for any option is the one that is saved.{{Text|Text=#### GMail SSL SMTP Relay relayhost <nowiki>=</nowiki> [smtp.gmail.com]:587  #authsasl_passwd smtp_sasl_auth_enable<nowiki>=</nowiki>yes smtp_sasl_password_maps <nowiki>=</nowiki> hash:chmod 600 /etc/postfix/sasl_passwd.db  #tls smtp_use_tls <nowiki>=<chmod 600 /nowiki> yes smtp_sasl_security_options <nowiki>=<etc/nowiki> noanonymous smtp_sasl_tls_security_options <nowiki>=<postfix/nowiki> noanonymoustls_policy smtp_tls_note_starttls_offer <nowiki>=<chmod 600 /nowiki> yes tls_random_source <nowiki>=<etc/nowiki> dev:postfix/devtls_policy.db</urandom smtp_tls_scert_verifydepth <nowikipre>=</nowiki> 5!-- smtp_tls_key_file<nowiki>=</nowiki>chown postfix /etc/pkipostfix/tls/gmail_relay/server.keysasl_passwd smtp_tls_cert_file<nowiki>=</nowiki>chown postfix /etc/pkipostfix/tls/gmail_relay/serversasl_passwd.pemdb smtpd_tls_ask_ccert <nowiki>=<chown postfix /nowiki> yes smtpd_tls_req_ccert <nowiki>=<etc/nowiki>no smtp_tls_enforce_peername <nowiki>=<postfix/nowiki> no}}tls_policyCreate chown postfix /etc/postfix/sasl_passwd file with your GMail login credentials that looks like below: {{Text|Text=gmailtls_policy.db--smtp.l.google.com user@gmail.com:passwordsmtp.gmail.com user@gmail.com:password}} Obviously, you need to change ''user'' to your username and ''password'' to your gmail password. <br>
Create the password database* Restart Postfix: <brpre>systemctl restart postfix.service</pre>
{{Code|postmap hash* Set Postifx to start on boot:/etc/<pre>systemctl enable postfix.service</sasl_passwd}}pre>
* Now try sending a mail, it should reach your Gmail account:
<pre>echo test 1 2 | mail -s "Test mail" user@gmail.com</pre>
Protect the files with your GMail login data:
{{Code|chmod 600 <b>NOTE:</etc/postfix/sasl_passwdchmod 600 /etc/postfix/sasl_passwdb> Some ISPs will block emails sent using this method.dbchown postfix /etc/postfix/sasl_passwdchown postfix /etc/postfix/sasl_passwd Looking for a work around.db}}
Restart Postfix== Troubleshooting ==* If you get the message " warning: SASL authentication failure: No worthy mechs found", install this package. yum install cyrus-sasl{,-plain}
{{Code|/etc/init.d/:Restart Postfix systemctl restart postfix restart}}
Now try sending a mail* Receive the following message: connect to smtp.gmail.com[2607:f8b0:400e:c05::6d]:587: Network is unreachable:To correct this problem, it should reach your gmail accountchange /etc/postfix/main.cf as follows: inet_protocol = ipv4:Restart postfix systemctl reload postfix
See also:<br>
[[Amahi_Mail_-_The_Free_Way]], not working on F14, yet.<br>[[Forward_System_Emails|Forward System Emails]]<br>[[Enable_Outgoing_Mail]], not working on F14, yet.<br>[[Monitor_System_Logs_via_E-mail|Monitor System Logs via E-mail]]<br>
12,424

edits