# Creating a no-reply email address

## dejima

I am building an application(PHP based) more like a social media that users would be sending messages and invites using the application's internal mail system. 

The application is running on the Web Server which is located on a different server than our mail server. I would like to create an email address like no-reply@domain.com  I would like this user to be able to send emails to users but did not want to receive any replies to the email. The php application would authenticate to the SMTP server(authentication is required)of our mail server and send the email to users but it should not receive replies.

How should I accomplish it? How would you approach this case?

I would also like to mention that I use Postfix and Dovecot on my mail server.

Thank you.

----------

## eccerr0r

What do you mean "no reply"?

Easiest way is to just delete all emails as they come in.  They can send but you never need to reply... I don't see a problem with this?

Other ways:

Set up a "vacation" script that deletes all mails as they come in and optionally send something back.

Set up a mail quota of 0 on the user or set the mail directory to something unreadable and unwritable by the user and delivery agent.  This depends on the local mail delivery system (I'm not familiar with postfix...)

Lie about your email address when sending - have no mail account ... This depends on the mail "client" (php script).  Yes this is virtually "spam" but if you don't want people replying, isn't this the same as spam for all intents and purposes?

----------

## dejima

I believe that you can put the on the /etc/aliases if this is set up as your alias_maps on postfix an entry

```
devnull: /dev/null
```

and then on the /etc/postfix/virtual if this is configured as your virtual_alias_maps an entry 

```
no-reply@domain.com devnull
```

My question is whether this no-reply user must be created as local user since I want my php application to use that user for authenticating to my SMTP server and send the emails.

----------

## khayyam

dejima ...

First I would assume you want to setup a relay from the webserver to mailsever ... the webserver postfix doesn't recieve but forwards outgoing mail to relayhost. In which case you would do something like the following:

/etc/postfix/main.cf

```
inet_interfaces = loopback-only

append_dot_mydomain = no

smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/relay_host

smtp_sasl_auth_enable = yes

smtp_sasl_security_options = noanonymous

smtp_sasl_tls_security_options = noanonymous

smtp_sasl_password_maps = hash:/etc/postfix/saslpass

smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

smtp_use_tls = yes

smtp_tls_note_starttls_offer = yes

smtp_tls_CApath = /etc/ssl/certs
```

/etc/postfix/relay_host

```
no-reply@domain.com [mail.domain.com]:587
```

/etc/postfix/tls_policy

```
mail.domain.com:587 encrypt
```

/etc/postfix/saslpass

```
no-reply@domain.com no-reply@domain.com:PASSWORD
```

Generate the hashes for the above files ...

```
# postmap /etc/postfix/sender_relay

# postmap /etc/postfix/saslpass

# postmap /etc/postfix/tls_policy
```

Next on the mailhost create a no-reply account and the relevant alias to send any mail delivered to /dev/null ...

```
# useradd -M -s /bin/false -p PASSWORD no-reply
```

/etc/postfix/main.cf

```
virtual_alias_maps = hash:/etc/postfix/virtual
```

/etc/aliases

```
devnull: /dev/null
```

/etc/postfix/virtual

```
no-reply@domain.com devnull@localhost
```

Create a hash of the virtual and aliases files ...

```
# postmap /etc/postfix/virtual

# newaliases
```

Reload postfix ..

```
/etc/init.d/postfix reload
```

So, mail To: no-reply should end up in /dev/null but mail from that account should be passed on to the recipient. Untested, but it should work.

HTH & best ... khayLast edited by khayyam on Thu Aug 09, 2012 5:00 pm; edited 1 time in total

----------

## dejima

 *khayyam wrote:*   

> dejima ...
> 
> First I would assume you want to setup a relay from the webserver to mailsever ... the webserver postfix doesn't recieve but forwards local mail to relayhost. In which case you would do something like the following:
> 
> /etc/postfix/main.cf
> ...

 

Thank you khayyam

To tell you the truth I don't think there is a need for me to to the first steps on the web server since php code will be the one that will take care of that, or do I?

But on the part what is needed to be done on the mailhost you are right.

----------

## khayyam

 *dejima wrote:*   

> To tell you the truth I don't think there is a need for me to to the first steps on the web server since php code will be the one that will take care of that, or do I? But on the part what is needed to be done on the mailhost you are right.

 

dejima ... your welcome ...

I would use the postfix relay as smtp is smtp and so its the right tool, I also have less trust of world facing php scripts, and with the relay to can do the following if there is some problem ...

```
# /usr/sbin/postconf 'defer_transports = smtp'

# /etc/init.d/postfix reload
```

and all mail is held ... until issuing:

```
# /usr/sbin/postconf 'defer_transports ='

# /etc/init.d/postfix reload

# /usr/sbin/postfix flush
```

You can even remove all mail in the que (see man mailq)

best ... khay

----------

## cach0rr0

i fear i may be late inasmuch as you seem to already have this covered off but:

 *dejima wrote:*   

> 
> 
> My question is whether this no-reply user must be created as local user since I want my php application to use that user for authenticating to my SMTP server and send the emails.

 

created locally on the web server, or mail server? 

on the web server: unlikely, as i doubt your php script particularly cares about local users on the web server. 

on the mail server: depends on what your auth backend is. If the ESMTP auth is done against your local users, then yes, you'd have to add that user. If it's done against say, sasldb2, then no. If it's done against a database, again, no. The user has to be added to whichever backend auth DB you're using, but unless that happens to be your local shadow users, adding the smtp account as a local is unnecessary, and a mailbox isn't required either way. But, authing and sending out says nothing with regards to how a mail should be treated when it comes *in*. So in essence, yes, sending to /dev/null would work, regardless of whether or not your auth backend looks at local users. 

HTH

----------

