LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 04-22-2010, 10:46 PM   #16
bakdong
Member
 
Registered: Apr 2009
Posts: 214

Rep: Reputation: 44

Quote:
Originally Posted by granth View Post
Sendmail is an MTA. Most people don't understand this concept...
Here here!

Very useful post. I'm archiving it for future reference. Thanks.
 
Old 04-22-2010, 10:52 PM   #17
bakdong
Member
 
Registered: Apr 2009
Posts: 214

Rep: Reputation: 44
Quote:
Originally Posted by narke View Post
It's very strange! Before I post the first message in the thread, I thought that my host should not have ability to send out email without really a try, because the host only have a private IP addres (10.x.x.x) and sit behind a firewall.

But, today after I really tried it, I found the story is actually a little different. It can send out message (via mutt) to my company email address, but it just can not send out message to external email adress (such as my gmail account). And, I have totally no idea how this can happen!
It's not that you're not sending, it's what the receiver is prepared to do with your message. There's a difference between relaying and receiving for a local domain. Relaying in an uncontrolled way opens the door to spammers so it is discouraged.
 
Old 04-27-2010, 11:19 AM   #18
ode
LQ Newbie
 
Registered: Nov 2005
Location: mx
Distribution: slackware
Posts: 5

Rep: Reputation: 2
here's what I do for sending mails from the command line:
in ~/.mailrc add accounts like this:
You can add as many as you like.
Code:
account myaccount {
 set from=myname@mydomain.com
 set smtp=smtpserver.mydomain.com
 set smtp-auth-user=myname@mydomain.com
 set smtp-auth-password=mypassword
 set smtp-auth=login
}
then I send quick mails like this:
Code:
mail -A myaccount -s subject somename@someserver.any
Hope this helps.
 
1 members found this post helpful.
Old 03-09-2014, 04:05 PM   #19
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,614

Rep: Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415
I think it's worth bumping this thread for a howto on how to do it with Postfix.

Quote:
Originally Posted by narke View Post
It's because my host is running some web services such wiki and a forum, their abilities of sending out email to users is based on the fact that the host gets smtp.
This is fairly common for PHP apps, and there's a technical reason. It's because the Linux implementation of PHP's standard library sends mail through an MTA. See: php.net/mail

Quote:
Originally Posted by granth View Post
Simple...
I looked at that, went very pale, and thought, f___ that I'm using Postfix.

Alan Hicks wrote the Postfix SlackBuild (on SBo) to use Dovecot SASL by default. Dovecot SASL isn't available when Postfix connects as a client, so you need to build Postfix to use Cyrus SASL instead. Fortunately, he made that easy:

Code:
SASL=cyrus ./postfix.SlackBuild
First, a safety precaution:

Code:
cp /etc/postfix/main.cf /etc/postfix/main.cf.dist
You need to set postfix up so that it can find its own aliases. Edit /etc/postfix/main.cf and add:

Code:
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
Build the aliases database:

Code:
postalias hash:/etc/postfix/aliases
At this point, Postfix is already set up to send and deliver mail locally. Test it out.

Start Postfix:

Code:
/etc/rc.d/rc.postfix start
In one terminal:

Code:
tail -f /var/log/maillog
And in another:

Code:
mail USERNAME
Now you're ready to set Postfix up to relay mail to GMail. Start by setting Postfix to only accept mail from the local machine, with the following setting in main.cf:

Code:
mynetworks_style = host
The main.cf settings for turning on security (when connecting as a client) and enabling support, specifically, for GMail's SMTP server, are the same as the ones on innumerable blogs, such as this one: Postfix: Configuring Gmail as Relay:

Code:
relayhost = [smtp.gmail.com]:587

#  use tls
smtp_use_tls=yes

# use sasl when authenticating to foreign SMTP servers
smtp_sasl_auth_enable = yes 

# path to password map file
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

# list of CAs to trust when verifying server certificate
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

# eliminates default security options which are imcompatible with gmail
smtp_sasl_security_options =
Then you add your SMTP login credentials to /etc/postfix/sasl_passwd:

Code:
[smtp.gmail.com]:587 username:password
Tell Postfix to recognize the credentials, and restart it:

Code:
postmap /etc/postfix/sasl_passwd
/etc/rc.d/rc.postfix restart
Fire up "mail" again, and send an email to a test address. It should arrive, and the maillog should show that it was routed through GMail.

Finally, set /etc/rc.d/rc.local to run Postfix on boot:

Code:
if [ -x /etc/rc.d/rc.postfix ]; then
    /etc/rc.d/rc.postfix start
fi
Success!

UPDATE:

And of course, imediately after writing that, I found out that it was better to just use ssmtp. Here's one blog entry on it: http://www.volcanic.co.uk/ruby-on-ra...-smtp-servers/

Last edited by dugan; 03-09-2014 at 06:32 PM.
 
Old 03-09-2014, 05:47 PM   #20
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.1
Posts: 1,479

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
No, that would be a reason to start a new thread instead of bringing an almost 4 year old thread back to life.

I don't know about you, but when I ask "How do I get X to do Y?" an answer of "Well, Z does Y this way..." is a waste of my time. If I had wanted to know that, I would have asked "What's the best way to do Y?".
 
Old 03-09-2014, 06:34 PM   #21
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,614

Rep: Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415
Quote:
Originally Posted by Richard Cranium View Post
I don't know about you, but when I ask "How do I get X to do Y?" an answer of "Well, Z does Y this way..." is a waste of my time. If I had wanted to know that, I would have asked "What's the best way to do Y?".
I don't agree with that. I personally think it's a good policy to treat all "How do I get X to do Y?" questions as actually asking "What's the best way to do Y?". The exception is when there are clear indications that nothing other than X will do.

And in this case, I obviously know why the question was asked.

Quote:
No, that would be a reason to start a new thread instead of bringing an almost 4 year old thread back to life.
Perhaps. But I think that having both the Postfix and Sendmail howtos in one thread will be convenient for people who search for this subject in the future.

Last edited by dugan; 03-09-2014 at 06:48 PM.
 
Old 03-10-2014, 09:33 AM   #22
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,034

Rep: Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755Reputation: 755
While you guys are talking about the relative merits of sendmail and postfix, I have question: I have HughesNet, no fixed-IP, no access from the outside world to my LAN (it's not allowed) and no viable alternatives; I live in the boonies in northeastern Michigan, no cable, no light pipes, no nuthin'. I also have a DSpace server (not here, on cable down the road a ways but, nope, you can't have a fixed-IP address and you can't get in from the outside, it's LAN only).

DSpace wants to send mail to users and it can on a LAN with sendmail. No problem. A couple of PHP web pages want to do the same thing, no problem on the LAN but mail bounces from gmail.com because of the send address being a LAN address. And DSpace wants a SMTP server. From Thunderbird, no problem. From sendmail, problem.

I don't want to add another layer of software; e.g., postfix that I have to maintain, I want to use the standard stuff that comes with Slackware; e.g., sendmail, that'll be enough fiddling and twiddling.

So, reading though the old part of this thread, it looks like setting up sendmail to do the job is feasible (although I tend to agree with the comments about one SMTP server to another SMTP server).

What would be the best way, without adding a bunch of software, to get sendmail to, say, gmail? Not, mind, just for me to do but for somebody else to do if I drop dead tomorrow?
 
Old 03-10-2014, 11:28 AM   #23
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,614

Rep: Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415
troynayne, if DSpace allows you to set the path to the sendmail binary (as PHP does; it's in php.ini), then use ssmtp. If it requires Sendmail to be running as a server, then see granth's post.

The ssmtp SlackBuild on SBo currently builds ssmtp without SSL support, which obviously doesn't work. I've found a patch to get it to build with SSL support on non-Debian systems, and I've asked the maintainer to apply it.

Last edited by dugan; 03-10-2014 at 12:54 PM.
 
Old 03-10-2014, 02:02 PM   #24
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,614

Rep: Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415Reputation: 1415
The question was never how to get Sendmail to relay mail through gmail; it was how to get PHP to relay mail through gmail.

I've updated my LEMP on Slackware guide with what I now think is the best solution.

Set PHP up to send mail through msmtp, and msmtp to send mail through GMail. Unlike, its competitors (like ssmtp), msmtp is still maintained.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Configure sendmail as gmail relay mexx20 Slackware 1 02-14-2009 10:01 AM
How to configure sendmail with gmail? athanatos Slackware 1 07-18-2006 04:37 PM
Can one configure sendmail to use an SMTP server? laggerific Linux - Software 1 02-16-2006 10:49 AM
configure sendmail to use a specific smtp server TheOneAndOnlySM Linux - Software 4 06-20-2004 05:15 AM
How to configure sendmail to use other smtp server? josealexandre Linux - Newbie 2 10-12-2003 05:09 PM


All times are GMT -5. The time now is 03:02 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration