Skip to main content
Corrected title based on text body - included the MTA
Link

How to set up smtpssmtp and send emails?

Tweeted twitter.com/#!/StackRaspi/status/436675893613064192
Source Link
omega
  • 201
  • 1
  • 2
  • 3

How to set up smtp and send emails?

Im new to raspberry pi.

I installed the raspian OS on it. I want to send emails from it using my gmail account. I want to send from the command line interface and from php scripts.

I followed this guide. http://iqjar.com/jar/sending-emails-from-the-raspberry-pi/

I did steps 1,2,3,4 from the link.

When I send an email using the code below using

echo "Test text" | mail -s "Test Mail" [email protected]

nothing happens, there is nothing printed on the screen, and I don't get the email.

On "revaliases", if I replace "mail.google" with "smtp.gmail", then I get back a message saying

send-mail: Cannot open mail.google.com:587

or

send-mail: Server didn't like our AUTH LOGIN (530 5.7.0 Must issue a STARTTLS command first. ml2sm3592928igb.10 - gsmtp)

Does anyone know how to fix this? Thanks

Here are the two files below:

ssmtp.conf

#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
# root=postmaster

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# mailhub=mail

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=raspberrypi

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES


[email protected]
mailhub=smtp.gmail.com:587
[email protected]
AuthPass=mypass
UseSTARTTLS=YES

revaliases

# sSMTP aliases
# 
# Format:   local_account:outgoing_address:mailhub
#
# Example: root:[email protected]:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.

root:[email protected]:mail.google.com:587