Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have add a user in linux called "mailer". I'm only using this user to send outgoing mail, not receive. What do I need to do in order use the following SMTP information to send outgoing mail?

$config['host'] = 'localhost';
$config['port'] = '25';
$config['secure'] = '';  //ssl or tls
$config['auth'] = 'true';
$config['username'] = 'mailer';
$config['password'] = '******';

update

Someone please help, how can I setup an account to send mail via SMTP?

update

Should I just be able to use SSH information as the username/password to send mail? The above configuration information is using PHPMailer via SMTP.

update

I ran a test to send email via PHPMailer and the mail logs show...

Aug 31 17:58:55 spireprod postfix/smtpd[14597]: disconnect from unknown[::1]
Aug 31 17:58:55 spireprod postfix/smtp[14601]: DA1491BC1084: to=<email@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.95.27]:25, delay=0.48, delays=0.12/0.01/0.12/0.23, dsn=2.0.0, status=sent (250 2.0.0 OK 1283291935 gy42si22156132ibb.26)
Aug 31 17:58:55 spireprod postfix/qmgr[941]: DA1491BC1084: removed

The problem is that I never received it!

share|improve this question
    
depends on how it was configured but if it was a simple setup then yes normal shell users. –  Prix Aug 28 '10 at 3:40
add comment

3 Answers 3

up vote 3 down vote accepted
+50

Have you tested whether the account can send mail?

There are a few ways of doing this, but the easiest is to telnet to port 25 (smtp) on your mailserver (try from the local console):

telnet localhost 25
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 myserver.com ESMTP Postfix
EHLO test.com
250-myserver.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from: mailer@myserver.com
250 2.1.0 Ok
rcpt to: test@testaddress.com
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: Test Message
Test
.
250 2.0.0 Ok: queued as 97B7D7640D0

If you see all those 250 OK messages and your message gets through to the test address, then the account is working fine.

If you get an error, then it will indicate where the problem is in the config. If you get an error after the MAIL FROM: command, then the user is not allowed to send mail at all.

If you get an error after the RCPT TO: command, then the user is not allowed to send mail to the test address.

If you get an error after the body of the mail, or the message never arrived, then check your maillog file. It is pretty useful to have another window with a live view of your maillog - tail -f /var/log/maillog will allow you to see what is happening on your mailserver as it happens. Very helpful when tracking things down.

You can also test by switching to the mailer user, and using the mail command to send a test message - view the maillog at the same time to see what happens.

share|improve this answer
    
Ok sweet, that went successfully. How do I take that successfully sent email and translate it to be able to send mail via localhost SMTP? –  Webnet Aug 31 '10 at 15:21
    
You shouldn't need to do anything - the local account is able to send email via SMTP already - you just proved it. –  dunxd Sep 1 '10 at 10:00
    
I'm soooo annoyed, it was ending up in my spam filter. What can I do about that? –  Webnet Sep 2 '10 at 0:48
    
Ha - I've seen that before. Those sorts of things make you kick yourself - but I'm sure you learnt a lot about your postfix system that will stand you in good stead! –  dunxd Sep 9 '10 at 13:03
add comment

In Postfix, you can have a user that will be authorized to send emails without having an actual mailbox.

This user will only be used to perform the send email operation, but postfix does not check that the username matches the email address used to send the email (if you don't ask it too).

In clear, user 'mailer' can send email with a 'mail from' field at foo@gmail.com, bar@hotmail.com, and so on... to anybody.

You can do that in two different way:

  1. If your postfix and your sending application are on the same machine (as in your example), set your postfix configuration as follow

    smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination

    mynetworks = 127.0.0.0/8

  2. If your client is on a different machine, setup SASL Authentication in postfix and set the restriction as follow

    smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination

When your user 'mailer' will send a email, postfix will control its credential before authorizing the 'RCPT TO' command. If it matches, 'mailer' will be authorized to perform the operation with any 'RCPT TO' value: mailer can send emails to anybody. The MAIL FROM field isn't controlled, so you can put anything in there.

share|improve this answer
    
Ok, I've removed permit_sasl_authenticated from smtpd_recipient_restrictions and myetworks is currently set to 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 which I will assume is fine. I ran the test that dunxd showed in his response and it worked great masking the main domain, thanks! –  Webnet Aug 31 '10 at 15:27
add comment

Postfix is a kind of interface, that accepts mails, and dispatch them depending on their domain destination. Postfix does not have users.

If you need to create users, and thus - on Linux/Unix - local mail recipients, there is the command

useradd

Do a man useradd. This will create the user ; check the options, you may have to specify the home directory and/or create it. Then please follow this link.

Usually the default on Linux is that the local mail will be accepted by Postfix and stored into /var/mail/user where user is a user who exists locally on the server.

Postfix, if configured for accepting and routing external mail, will decide depending on the domain of the mail address (the part after the @) if it has to store it locally (eg user exists locally, no domain is specified or the domain matches the mydestination domains specified in main.cf), or forward it to a relay, depending on the default or the transport table.

Typically a domain not known will be forwarded to the default relay, or Postfix will manage to pass the mail to the destination server based on the DNS MX entries of the destination domain.

share|improve this answer
2  
Adding real accounts is unnecessary and potentially insecure. I prefer having virtual users with user account information stored in MySQL or OpenLDAP isolated from /etc/passwd. –  Janne Pikkarainen Aug 28 '10 at 7:22
1  
All of my incoming mail comes in through Google apps, I only use SMTP on the server for outgoing mail, which is configured. I only need to add users. So if I add a user register then it will work for all domain names? –  Webnet Aug 28 '10 at 16:59
    
All domains names in mydestination. –  ring0 Aug 28 '10 at 17:55
add comment

Your Answer

 
discard

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.