TurnKey Linux Virtual Appliance Library

Configure php mail in lamp appliance with gmail

Hi,

I'm really new to turnkey and I'm starting to set up a small project in the lamp virtual appliance of turnkey 12.

My goal is to create a internal web server for a small company. I set up everything and all is working fine (is been incredibly easy so far working with this great product). My problem now is that I need to set up a gmail account with postfix and I have no clue how is that possible, Is there a tutorial available on this site? Is there any dependency needed for postfix to work with gmail?

I have configure an ubuntu server instead of postfix with msmtp and was really easy, can I install it on the server?

Regards.

Chris Musty's picture

Postfix

Here is a tutorial on what you want, I think!

Postfix is an MTA so it should send (from localhost) emails out of the box...

Chris Musty

Director

Specialised Technologies

Jeremy's picture

Beat me again Chris! :)

Or perhaps I'm just getting slow! :)

@Rodrigo - Curious why you would setup postfix with msmtp? AFAIK postfix (a full MTA as Chris states) provides all the functionality of msmtp (which only does outgoing mail - ie SMTP) so not clear why you would use both? I've never used msmtp but it seems like a good lightweight alternative if you only want to send mail out, but with postfix as well it would seem redundant.

Simple and Easy

@Jeremy,

I know that postfix is the whole deal in mailing, my problem is that I have to spend to much time configuring it. I only want to send mails, not receive. 

I know how to do it with msmtp (actually I did it already on the appliance), and I don't have time to properly configure it. 

Although I have read the tutorial and some day when I have time (on work vacations) I will give it a try.

 

Regards.


Chris Musty's picture

Already Setup

This is Turnkey remember!

You can send emails with a simple PHP script without any opther configuration.

Just remember that postfix is bound to localhost.

If you want to prevent being flagged as spam there a few hoops you need to jump through.

I use the Joomla and Wordpress appliances (Based on LAMP) and do nothing more than setup a newsletter plugin then send out emails from the appliance. One client has 6,000 subscribers and sends out on average once a week. Replies are not important but we put an address in the reply to field which is a gmail account and check it when we have to in case someone decides to give feedback. You can always ignore this step.

Chris Musty

Director

Specialised Technologies

Jeremy's picture

I just had a look at the link Chris posted

And although it looks pretty good, it's probably a bit in depth for what you'll need to do (includes instructions on installing postfix from source, etc) so there's only a small amount of it that you'd actually need to do to get postfix to relay emails through gmail's smtp. A quick google turned up heaps of results on how to configure postfix to relay through gmail and it looks pretty easy, just a case of minor modifications to the existing postfix config.

But like Chris says above, it's configured to send emails OOTB so unless you have some reason to relay through gmail, then it should just work as it is...

Chris Musty's picture

How are you sending emails?

Maybe we should ask what you are trying to achieve like sending from php mailer or system notifications etc

Chris Musty

Director

Specialised Technologies

Usage

Chris,

The usage I intend to do is to send system mails and php mails.

The reason that I didn't use postfix is that for some reason the mails never reach me. For that I intend to use the gmail account to see what is happening with that.

I will try to give it another shot with the default configuration to see what is happening.

Regards.


Chris Musty's picture

SPAM

You will find that postfix is fine but your ISP (Internet Service Provider) is flagging the email as spam for one or more of the following reasons.

  1. Dynamic IP on appliance - even though the IP may be static in the respect it does not chsnge Amazon list it as dynamic and Trend Micro via their DUL list flag your server as a big bad spam producing machine.
  2. DUL (Dialup Users List - bad acronym really) is a list of all the SOHO and once off servers that have not specifically proven they are ok to send emails.
  3. Bad HELO name - this is the fully qualified domain name of the server. If its wrong (most would be if using TKL) then you will probably get flagged as SPAM
  4. SPF (Sender Policy Framework) Records - at a zone manager level you need to specify this TXT record so emails have the status as "Pass" reducing the risk of being spoofed and giving recipients a nice warm feeling that you are a good guy.

I have listed out how to fix this issue in THIS thread and thought I had finished a wiki entry but just checked it and found it was half done! ARGH!

In addition to the info provided you can check your IP status with Trend HERE

Good luck and any questions, reply to the thread!

Chris Musty

Director

Specialised Technologies

Jeremy's picture

Glad you're here Chris!

Having you here and sharing your knowledge on the forums is a real plus mate! I know a bit, but there are many holes in my knowledge and as it's all self taught I'm often not sure if it's best practice, so great to have you around.

Chris Musty's picture

Paying it Forward

We all like to share...

Chris Musty

Director

Specialised Technologies

Certificates problems

Hi,

I try to follow the tutotrial in http://souptonuts.sourceforge.net/postfix_tutorial.html creating the certificated according this tutorial http://www.debian-administration.org/articles/284 and I'm having this problems in the log (/var/log/mail.info).

Oct 5 17:28:09 lamp postfix/smtp[4854]: setting up TLS connection to smtp.gmail.com[74.125.134.108]:587
Oct 5 17:28:09 lamp postfix/smtp[4853]: setting up TLS connection to smtp.gmail.com[74.125.134.109]:587
Oct 5 17:28:10 lamp postfix/smtp[4854]: Verified TLS connection established to smtp.gmail.com[74.125.134.108]:587: TLSv1 with cipher RC4-SHA (128/128 bits)
Oct 5 17:28:10 lamp postfix/smtp[4853]: Verified TLS connection established to smtp.gmail.com[74.125.134.109]:587: TLSv1 with cipher RC4-SHA (128/128 bits)
Oct 5 17:28:10 lamp postfix/smtp[4854]: warning: SASL authentication failure: No worthy mechs found
Oct 5 17:28:10 lamp postfix/smtp[4854]: CDD6C7D73: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.134.108]: no mechanism available
Oct 5 17:28:10 lamp postfix/smtp[4853]: warning: SASL authentication failure: No worthy mechs found
Oct 5 17:28:10 lamp postfix/smtp[4853]: F16FB702C: SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.134.109]: no mechanism available

So I google that and this is what I try to follow this http://www.interphero.com/?p=221 and now my log says this:

Oct 5 17:28:11 lamp postfix/smtp[4853]: setting up TLS connection to smtp.gmail.com[74.125.134.108]:587
Oct 5 17:28:12 lamp postfix/smtp[4854]: Verified TLS connection established to smtp.gmail.com[74.125.134.109]:587: TLSv1 with cipher RC4-SHA (128/128 bits)
Oct 5 17:28:12 lamp postfix/smtp[4853]: Verified TLS connection established to smtp.gmail.com[74.125.134.108]:587: TLSv1 with cipher RC4-SHA (128/128 bits)
Oct 5 17:28:12 lamp postfix/smtp[4854]: warning: SASL authentication failure: No worthy mechs found
Oct 5 17:28:12 lamp postfix/smtp[4853]: warning: SASL authentication failure: No worthy mechs found

Oct 5 17:28:12 lamp postfix/smtp[4853]: F16FB702C: to=<****@gmail.com>, relay=smtp.gmail.com[74.125.134.108]:587, delay=21246, delays=21243/0.06/3.5/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.gmail.com[74.125.134.108]: no mechanism available)

 

I don't know what else to do, any help will be apreciated.

Regards


Chris Musty's picture

Complicating the issue

If you divert all your mail through Gmail's SMTP you will have to play by their restrictions. I know one of them is no more than 100 emails an hour - useless for mailing lists.

You can configure your VPS to send emails as suggested above without much work and thats what I recomend.

As for certificates I generally dont bother as SPF and not being on a spam list work great but if you really want to certify emails there are tons of tutorials for getting it working from your VPS.

Chris Musty

Director

Specialised Technologies

ELGG Postfix

Hi, I am using a turnkey ELGG as my company Intranet. Postfix came bound to localhost.

I'm trying to configure Postfix to sen mails through company's webmail, but I can't seem to get it right.

Mails are sent by the local elgg user instead sending them from an existing mail account.

I've follow some tutorials to change the sender but didn't seem to work.

there's the log

tail /var/log/mail.log
Oct 26 13:45:55 elgg postfix/pickup[5415]: 75B8210D87CC: uid=33 from=<www-data>
Oct 26 13:45:55 elgg postfix/cleanup[5787]: 75B8210D87CC: message-id=<20121026134555.75B8210D87CC@localhost>
Oct 26 13:45:55 elgg postfix/qmgr[771]: 75B8210D87CC: from=<www-data@localhost>, size=757, nrcpt=1 (queue active)
Oct 26 13:45:56 elgg postfix/smtp[5790]: 75B8210D87CC: to=<user@domain.com.ar>, relay=mail.domain.com.ar[xxx.xxx.xxx.xxx]:25, delay=1.5, delays=0.2/0.27/0.69/0.31, dsn=5.5.2, status=bounced (host mail.domain.com.ar[190.221.168.106] said: 504 5.5.2 <www-data@localhost>: Sender address rejected: need fully-qualified address (in reply to RCPT TO command))
Oct 26 13:45:56 elgg postfix/cleanup[5787]: D1D1D10D87CD: message-id=<20121026134556.D1D1D10D87CD@localhost>
Oct 26 13:45:56 elgg postfix/bounce[5791]: 75B8210D87CC: sender non-delivery notification: D1D1D10D87CD
Oct 26 13:45:56 elgg postfix/qmgr[771]: D1D1D10D87CD: from=<>, size=2772, nrcpt=1 (queue active)
Oct 26 13:45:56 elgg postfix/qmgr[771]: 75B8210D87CC: removed
Oct 26 13:45:57 elgg postfix/local[5792]: D1D1D10D87CD: to=<www-data@localhost>, relay=local, delay=0.14, delays=0.09/0/0/0.05, dsn=2.0.0, status=sent (delivered to mailbox)
Oct 26 13:45:57 elgg postfix/qmgr[771]: D1D1D10D87CD: removed
 

here's config

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = localhost
mailbox_size_limit = 0
mydestination = localdomain, localhost, localhost.localdomain, localhost
myhostname = localhost
mynetworks = 127.0.0.0/8
readme_directory = no
recipient_delimiter = +
relayhost = mail.teceng-gaming.com.ar
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
smtp_sasl_security_options =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
 

Thanx in advance.

ELGG Postfix SOLVED

504 5.5.2 <www-data@localhost>: Sender address rejected: need fully-qualified address (in reply to RCPT TO command)) SOLVED:


Problem was not authentication at all. The reply-to mail address was invalid.

Solved the issue following this procedure to masquerade outgoing smtp address

http://www.cyberciti.biz/tips/howto-postfix-masquerade-change-email-mail-address.html

Fix for No Mechanisms Available Postfix

After killing myself and following the Standard Postfix Gmail Relay posts on the Internet, it Appears Turnkey Builds do not have SASL libs installed by default.  To fix the No Mechanisms Found error:

 

Mar 29 15:10:36 www postfix/smtp[6927]: 7B39F1232BC: SASL authentication failed; cannot authenticate to server smtp.gmail.com[173.194.70.108]: no mechanism available

You need to install the package libsasl2-modules and restart postfix again.

Jeremy's picture

Thanks for posting Dan

No doubt someone else will find that info useful! :)

fabvlvs's picture

count me among them.

count me among them.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)