Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to send an email through Google from my localhost. (via PHP5.3)

But Google keeps on blocking my requests.

I tried to follow the solutions given to a few similar questions, but for some reason they do not work.

I followed these instructions to configure it -

Now for the config data:

  • my file looks like that:

relayhost = []:587
smtp_fallback_relay = []
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

  • my sasl_passwd looks like that:


  • and that is how the mail.log rows look like:

Dec 14 10:24:50 COMP-NAME postfix/pickup[5185]: 1C3987E0EDD: uid=33 from=

Dec 14 10:24:50 COMP-NAME postfix/cleanup[5499]: 1C3987E0EDD: message-id=<20121214082450.1C3987E0EDD@COMP-NAME.localdomain>

Dec 14 10:24:50 COMP-NAME postfix/qmgr[5186]: 1C3987E0EDD: from=, size=483, nrcpt=1 (queue active)

Dec 14 10:24:50 COMP-NAME postfix/smtp[5501]: 1C3987E0EDD: to=,[]:587, delay=0.61, delays=0.19/0/0.32/0.1, dsn=5.7.0, status=bounced (host[] said: 530 5.7.0 Must issue a STARTTLS command first. w3sm8024250eel.17 (in reply to MAIL FROM command))

Dec 14 10:24:50 COMP-NAME postfix/cleanup[5499]: C20677E0EDE: message-id=<20121214082450.C20677E0EDE@COMP-NAME.localdomain>

Dec 14 10:24:50 COMP-NAME postfix/bounce[5502]: 1C3987E0EDD: sender non-delivery notification: C20677E0EDE

Dec 14 10:24:50 COMP-NAME postfix/qmgr[5186]: C20677E0EDE: from=<>, size=2532, nrcpt=1 (queue active)

Dec 14 10:24:50 COMP-NAME postfix/qmgr[5186]: 1C3987E0EDD: removed

share|improve this question
my guess is that it is somehow related to Dec 14 10:24:50 COMP-NAME postfix/qmgr[5186]: 1C3987E0EDD: from=<www-data@COMP-NAME.localdomain>, size=483, nrcpt=1 (queue active) how do I change the 'from'? to a legal one? – gilmad Dec 14 '12 at 8:53
up vote 9 down vote accepted

You need to enable TLS in Postfix's SMTP client, since Google requires it. This is indicated by them in the message "Must issue a STARTTLS command".

In /etc/postfix/, you want something like this:

smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

and then in /etc/postfix/tls_policy:

[]:587 encrypt

The left hand side in tls_policy must appear exactly the same as your relayhost entry in

Remember to run postmap on /etc/postfix/tls_policy after creating or changing it as required.

You can find more details in Postfix's TLS documentation.

share|improve this answer
PS. You may also have a sender address problem, but currently you're not getting that far. You'll need to fix the STARTTLS issue before you'll find out. – Robie Basak Dec 14 '12 at 10:05
That worked! Thanks a lot! – gilmad Dec 14 '12 at 13:02

This very simple tutorial helped me a lot to do it.

It gives quite the same info but it worked for me.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.