Re: [opensuse] A simple way to send email, from the command line, to a gmail account.
Hello,
hmm, I'm either too blonde or need more coffee to fully understand what you mean... :-)
Sending emails TO a gmail.com account is quite easy/trivial, even from the shell, without installing the ssmtp package you propose (no pun intended):
---
martin@steelrose:~> mailx foo@gmail.com
Subject: Test to gmail.com
Hello world!
.
EOT
--
Jul 15 12:14:00 steelrose postfix/pickup[7215]: 5DFE5124BBA: uid=1000 from=<martin>
Jul 15 12:14:00 steelrose postfix/cleanup[7437]: 5DFE5124BBA: message-id=<20080715101400.5DFE5124BBA@steelrose.local>
Jul 15 12:14:00 steelrose postfix/qmgr[5223]: 5DFE5124BBA: from=
From: Mark V
To: suse Sent: Tuesday, July 15, 2008 9:17:27 AM Subject: [opensuse] A simple way to send email, from the command line, to a gmail account. The simplest solution I've found is to install the ssmtp package. I've packaged this on the OBS for all platforms except Debian and Ubuntu fdistros - If someone would like to get them building let me know and I'll add them as a maintainer.
This use case is quite specific, and is just what ssmtp targets: "extremely simple MTA to get mail off the system to a mail hub",.
The bonus is this allows you to send mail to a gmail account without any third parties, or configuring you local machine as....? (well its beyond me what I'd need to do)
I haven't yet worked out howto pass username and password other than via /etc/ssmtp/ssmtp.conf
I'd appreciate it anyone has additional tips or can point to a simpler set-up.....?
# # Begin bash session as ordinary user # su MY_REPO=http://download.opensuse.org/repositories/home:mvyver/openSUSE_11.0
zypper addrepo --check $MY_REPO "mvyver Repository" zypper install --repo $MY_REPO ssmtp
GMAIL_USER=...... GMAIL_PSWD=......
cat
mail -v -s "Testing SSMTP" $GMAIL_USER@gmail.com < This should go direct to gmail, "do not pass ISP do not pay fees".... EOM # # End bash session as ordinary user #
Preparation: --------------- - make sure sendmail is deactivated: # service sendmail stop - Check sendmail won't restart on reboot: YaST Control Center>>System>>System Services (runlevel) - check that the mta alternative does not exist # ls -la /etc/alternatives/mta # should not exist
Troubleshooting: -------------------- - If the /et/claternatives/mta exists before you install ssmtp, you can remove it: # /usr/sbin/update-alternatives --remove mta note that on your system might be different on mine it was /usr/bin/mailx
HTH? Mark -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tue, Jul 15, 2008 at 8:28 PM, Martin Mielke
Hello,
hmm, I'm either too blonde or need more coffee to fully understand what you mean... :-)
Sending emails TO a gmail.com account is quite easy/trivial, even from the shell, without installing the ssmtp package you propose (no pun intended): --- martin@steelrose:~> mailx foo@gmail.com Subject: Test to gmail.com
Hello world!
. EOT
-- Jul 15 12:14:00 steelrose postfix/pickup[7215]: 5DFE5124BBA: uid=1000 from=<martin> Jul 15 12:14:00 steelrose postfix/cleanup[7437]: 5DFE5124BBA: message-id=<20080715101400.5DFE5124BBA@steelrose.local> Jul 15 12:14:00 steelrose postfix/qmgr[5223]: 5DFE5124BBA: from=
, size=474, nrcpt=1 (queue active) Jul 15 12:14:04 steelrose postfix/smtp[7439]: 5DFE5124BBA: to= , relay=gmail-smtp-in.l.google.com[72.14.215.114]:25, delay=3.8, delays=0.25/0.04/1.4/2.1, dsn=2.0.0, status=sent (250 2.0.0 OK 1216116844 z31si3606hub.14) -- As you can see, the outgoing email domain is also rewritten to use a FQDN so a reply can find its way back and the test email hits gmail.com servers straight away.
So is there any advantage over Postfix that I'm not aware of?
Quite possibly not. I'm not familiar with postfix or sendmail, i.e. have never used either. What would be the postfix configuration steps - bear in mind I don't have any ISP providing me with a mail account. Hopefully the config is much simpler than the two cat commands I gave. Also postfix/sendmail may come into their own where more than one person needs this functioanlity - I haven't tried to set authentication from user specific files. One _big_ (for me) issue I can think of is that I don't need to open any ports in my firewall - I think sendmail/postfix would require this? As the ssmtp descriptions says - it pretty much does only one thing, so is really only suitable where that one thing is all that is required. Mark
Cheers, Martin
----- Original Message ----
From: Mark V
To: suse Sent: Tuesday, July 15, 2008 9:17:27 AM Subject: [opensuse] A simple way to send email, from the command line, to a gmail account. The simplest solution I've found is to install the ssmtp package. I've packaged this on the OBS for all platforms except Debian and Ubuntu fdistros - If someone would like to get them building let me know and I'll add them as a maintainer.
This use case is quite specific, and is just what ssmtp targets: "extremely simple MTA to get mail off the system to a mail hub",.
The bonus is this allows you to send mail to a gmail account without any third parties, or configuring you local machine as....? (well its beyond me what I'd need to do)
I haven't yet worked out howto pass username and password other than via /etc/ssmtp/ssmtp.conf
I'd appreciate it anyone has additional tips or can point to a simpler set-up.....?
# # Begin bash session as ordinary user # su MY_REPO=http://download.opensuse.org/repositories/home:mvyver/openSUSE_11.0
zypper addrepo --check $MY_REPO "mvyver Repository" zypper install --repo $MY_REPO ssmtp
GMAIL_USER=...... GMAIL_PSWD=......
cat
mail -v -s "Testing SSMTP" $GMAIL_USER@gmail.com < This should go direct to gmail, "do not pass ISP do not pay fees".... EOM # # End bash session as ordinary user #
Preparation: --------------- - make sure sendmail is deactivated: # service sendmail stop - Check sendmail won't restart on reboot: YaST Control Center>>System>>System Services (runlevel) - check that the mta alternative does not exist # ls -la /etc/alternatives/mta # should not exist
Troubleshooting: -------------------- - If the /et/claternatives/mta exists before you install ssmtp, you can remove it: # /usr/sbin/update-alternatives --remove mta note that on your system might be different on mine it was /usr/bin/mailx
HTH? Mark -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Mark V wrote:
Quite possibly not. I'm not familiar with postfix or sendmail, i.e. have never used either. What would be the postfix configuration steps - bear in mind I don't have any ISP providing me with a mail account.
You don't need to do anything. I'm pretty certain the default postfix config will work straight out of the box. Provided you have 1) internet connectivity and 2) access to a name-server.
One _big_ (for me) issue I can think of is that I don't need to open any ports in my firewall - I think sendmail/postfix would require this?
No, not for sending, only if you would also want to receive email. /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tue, Jul 15, 2008 at 10:54 PM, Per Jessen
Mark V wrote:
Quite possibly not. I'm not familiar with postfix or sendmail, i.e. have never used either. What would be the postfix configuration steps - bear in mind I don't have any ISP providing me with a mail account.
You don't need to do anything. I'm pretty certain the default postfix config will work straight out of the box. Provided you have 1) internet connectivity and 2) access to a name-server.
One _big_ (for me) issue I can think of is that I don't need to open any ports in my firewall - I think sendmail/postfix would require this?
No, not for sending, only if you would also want to receive email.
Hi Martin, Carlos, Sandy, Per Thanks for the feedback. So it seems Postfix could be configured or require no configuration. Interesting that sendmail doesn't get a mention. One positive from the exercise is that there is now a ssmtp package in the buildservice for all platforms except Debian/Ubuntu :) Cheers Mark
/Per Jessen, Zürich
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Mark V wrote:
Hi Martin, Carlos, Sandy, Per Thanks for the feedback. So it seems Postfix could be configured or require no configuration. Interesting that sendmail doesn't get a mention.
In my personal opinion, Postfix is much easier to deal with. The learning curve is far less steep, and the basic concepts are easily understood. It does get complex too, but not until you need it - whereas sendmail starts out being very complex (IMO). /Per Jessen, Zürich -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The Tuesday 2008-07-15 at 03:28 -0700, Martin Mielke wrote:
Hello,
hmm, I'm either too blonde or need more coffee to fully understand what you mean... :-)
Sending emails TO a gmail.com account is quite easy/trivial, even from the shell, without installing the ssmtp package you propose (no pun intended):
--- martin@steelrose:~> mailx foo@gmail.com Subject: Test to gmail.com
Hello world!
. EOT
Is not sending "TO", but using the gmail relay to send "FROM" you own account at gmail, if I understand correctly. It is not trivial either with postfix, but it is easy; you have to change a few files. If I don't miss any, it is (assuming your account is "email@gmail.con"): /etc/postfix/sasl_passwd: email@gmail.con email@gmail.con@PASSWD /etc/postfix/sender_relayhost: email@gmail.con [smtp.gmail.com] /etc/postfix/virtual: email@gmail.con localusername {optative} /etc/postfix/main.cf: smtp_sasl_auth_enable = yes smtp_sender_dependent_authentication = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_mechanism_filter = cram-md5, login I think that's it. Of course, you have first to let Yast configure postfix with a default configuration, and later we depart from default in that mail which from is set to "email@gmail.con" is sent to the relay host of gmail, instead of the default relay if any, or being handled by postfix directly. The advantage is that you can define several relay hosts for different accounts or different users in the system. On the other hand, the command "mail" (aka mailx) can configure accounts and can send from the command line. From the man page: account myisp { set folder=imaps://mylogin@imap.myisp.example set record=+Sent set from="myname@myisp.example (My Name)" set smtp=smtp.myisp.example } Ie, I believe it is possible to send mail to the gmail smtp server using "mail" directly, from the command line, without intervention from postfix, if configured properly. But don't ask me how to configure it, I dunno - it is a long man page ;-) PS: the .con instead of .com is intentional for malign bots ;-) - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4-svn0 (GNU/Linux) iD8DBQFIfIhNtTMYHG2NR9URAg7dAJsFZ3ZX9XbYRoChecBrIO7hbikHmQCfUeZU rYnnFWbe6QHurjlCVhYowMU= =piG+ -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Carlos E. R. wrote:
The Tuesday 2008-07-15 at 03:28 -0700, Martin Mielke wrote:
Hello,
hmm, I'm either too blonde or need more coffee to fully understand what you mean... :-)
Sending emails TO a gmail.com account is quite easy/trivial, even from the shell, without installing the ssmtp package you propose (no pun intended):
This depends on gmail accepting mail from your ip at all, and that is a big hurdle. As more bots appear on residential ips all the time it will likely that Gmail will not accept mail from dynamic ips unless they authenticate.
It is not trivial either with postfix, but it is easy; you have to change a few files. If I don't miss any, it is (assuming your account is "email@gmail.con"):
/etc/postfix/sasl_passwd:
email@gmail.con email@gmail.con@PASSWD
email@gmail.con loginname:password
/etc/postfix/sender_relayhost:
email@gmail.con [smtp.gmail.com]
/etc/postfix/virtual:
email@gmail.con localusername {optative}
You probably have to reverse the localpart and the email adress. You don't want to use the localusername with the localhostname as sender address. That is most likely not a routable address.
/etc/postfix/main.cf:
smtp_sasl_auth_enable = yes smtp_sender_dependent_authentication = yes
smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_mechanism_filter = cram-md5, login
This is an example I use to show a configuration with more than one user: /etc/postfix/main.cf: sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/smtp_relayhost_auth smtp_sasl_security_options = noanonymous smtp_sender_dependent_authentication = yes /etc/postfix/sender_relayhost user1@gmx.de [mail.gmx.de] user2@gmx.de [mail.gmx.de] /etc/postfix/smtp_relayhost_auth: user1@gmx.de user1@gmx.de:password1 user2@gmx.de user2@gmx.de:password2 -- Sandy List replies only please! Please address PMs to: news-reply2 (@) japantest (.) homelinux (.) com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Carlos E. R.
-
Mark V
-
Martin Mielke
-
Per Jessen
-
Sandy Drobic