fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Basic Email setup

Wed Jul 11, 2012 1:10 am

Hey guys,
I'm working on my Pi and have been trying to get basic email capability setup for the last several hours. I only need the ability to send email.
In the past I would just install bsd-mailx on debian and it would be able to email outside addresses.

I've installed bsd-mailx but when I try to email I never receive it on the outside.

sample syntax:
echo "something" | mail -s "some subject" abc@yahoo.com

I use this for reporting with some scripts I use so it needs to be a command line solution.
Any help is greatly appreciated!

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Basic Email setup

Wed Jul 11, 2012 1:39 am

I found a referrence online about an email error log in /var/mail/username

Code: Select all

From MAILER-DAEMON  Wed Jul 11 01:31:42 2012
Return-Path: <MAILER-DAEMON>
Received: from localhost6.localdomain6 (pwnpi [127.0.0.1])
        by localhost6.localdomain6 (8.14.3/8.14.3/Debian-9.4) with ESMTP id q6B0VfNa002517
        for <root@localhost6.localdomain6>; Wed, 11 Jul 2012 01:31:42 +0100
Received: from localhost (localhost)
        by localhost6.localdomain6 (8.14.3/8.14.3/Submit) id q6B0VfxF002515;
        Wed, 11 Jul 2012 01:31:42 +0100
Date: Wed, 11 Jul 2012 01:31:42 +0100
From: Mail Delivery Subsystem <MAILER-DAEMON@localhost6.localdomain6>
Message-Id: <201207110031.q6B0VfxF002515@localhost6.localdomain6>
To: root@localhost6.localdomain6
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary="q6B0VfxF002515.1341966702/localhost6.localdomain6"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)

This is a MIME-encapsulated message

--q6B0VfxF002515.1341966702/localhost6.localdomain6

The original message was received at Wed, 11 Jul 2012 01:31:41 +0100
from root@localhost

   ----- The following addresses had permanent fatal errors -----
test
    (reason: 550 5.1.1 <test@localhost6.localdomain6>... User unknown)
    (expanded from: test)

   ----- Transcript of session follows -----
... while talking to [127.0.0.1]:
>>> DATA
<<< 550 5.1.1 <test@localhost6.localdomain6>... User unknown
550 5.1.1 test... User unknown

--q6B0VfxF002515.1341966702/localhost6.localdomain6
Content-Type: message/delivery-status

Reporting-MTA: dns; localhost6.localdomain6
Arrival-Date: Wed, 11 Jul 2012 01:31:41 +0100

Final-Recipient: RFC822; test@localhost6.localdomain6
Action: failed
Status: 5.1.1
Remote-MTA: DNS; [127.0.0.1]
Diagnostic-Code: SMTP; 550 5.1.1 <test@localhost6.localdomain6>... User unknown
Last-Attempt-Date: Wed, 11 Jul 2012 01:31:41 +0100

--q6B0VfxF002515.1341966702/localhost6.localdomain6
Content-Type: message/rfc822

Return-Path: <root>
Received: (from root@localhost)
        by localhost6.localdomain6 (8.14.3/8.14.3/Submit) id q6B0VfxE002515;
        Wed, 11 Jul 2012 01:31:41 +0100
Date: Wed, 11 Jul 2012 01:31:41 +0100
From: root <root>
Message-Id: <201207110031.q6B0VfxE002515@localhost6.localdomain6>

test

--q6B0VfxF002515.1341966702/localhost6.localdomain6--

From MAILER-DAEMON  Wed Jul 11 02:26:40 2012
Return-Path: <MAILER-DAEMON>
Received: from localhost6.localdomain6 (pwnpi [127.0.0.1])
        by localhost6.localdomain6 (8.14.3/8.14.3/Debian-9.4) with ESMTP id q6B1QdcD002918
        for <root@localhost6.localdomain6>; Wed, 11 Jul 2012 02:26:40 +0100
Received: from localhost (localhost)
        by localhost6.localdomain6 (8.14.3/8.14.3/Submit) id q6B1QdPu002916;
        Wed, 11 Jul 2012 02:26:40 +0100
Date: Wed, 11 Jul 2012 02:26:40 +0100
From: Mail Delivery Subsystem <MAILER-DAEMON@localhost6.localdomain6>
Message-Id: <201207110126.q6B1QdPu002916@localhost6.localdomain6>
To: root@localhost6.localdomain6
MIME-Version: 1.0
Content-Type: multipart/report; report-type=delivery-status;
        boundary="q6B1QdPu002916.1341970000/localhost6.localdomain6"
Subject: Returned mail: see transcript for details
Auto-Submitted: auto-generated (failure)

This is a MIME-encapsulated message

--q6B1QdPu002916.1341970000/localhost6.localdomain6

The original message was received at Wed, 11 Jul 2012 02:26:39 +0100
from root@localhost

   ----- The following addresses had permanent fatal errors -----
.
    (reason: 550 5.1.1 <.@localhost6.localdomain6>... User unknown)
    (expanded from: .)

   ----- Transcript of session follows -----
... while talking to [127.0.0.1]:
>>> DATA
<<< 550 5.1.1 <.@localhost6.localdomain6>... User unknown
550 5.1.1 .... User unknown

--q6B1QdPu002916.1341970000/localhost6.localdomain6
Content-Type: message/delivery-status

Reporting-MTA: dns; localhost6.localdomain6
Arrival-Date: Wed, 11 Jul 2012 02:26:39 +0100

Final-Recipient: RFC822; .@localhost6.localdomain6
Action: failed
Status: 5.1.1
Remote-MTA: DNS; [127.0.0.1]
Diagnostic-Code: SMTP; 550 5.1.1 <.@localhost6.localdomain6>... User unknown
Last-Attempt-Date: Wed, 11 Jul 2012 02:26:39 +0100

--q6B1QdPu002916.1341970000/localhost6.localdomain6
Content-Type: message/rfc822

Return-Path: <root>
Received: (from root@localhost)
        by localhost6.localdomain6 (8.14.3/8.14.3/Submit) id q6B1QdPt002916;
        Wed, 11 Jul 2012 02:26:39 +0100
Date: Wed, 11 Jul 2012 02:26:39 +0100
From: root <root>
Message-Id: <201207110126.q6B1QdPt002916@localhost6.localdomain6>
To: something@gmail.com
Subject: testing
Cc: .

testing

--q6B1QdPu002916.1341970000/localhost6.localdomain6--
It looks like my smtp gateway isn't configured correctly...
Looking at the logs on my other vm's it's possible my exchange server at work has been filling in the gaps for my poorly configured boxes...

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Basic Email setup

Wed Jul 11, 2012 2:55 am

[SOLVED]

I wasn't able to find anything about using BSD but I was able to get Heirloom working great following these instructions.
http://www.thelinuxtips.com/2011/09/sen ... -in-linux/

spud693
Posts: 7
Joined: Sun Jul 08, 2012 9:53 pm

Re: Basic Email setup

Wed Jul 18, 2012 9:22 pm

hi there - just thoughti would pick your brain as it appears you have succeeded where i have not!

i have a LAMP server running a blog, and i require the ability to send email so my contact form will work correctly. I triedfollowing the instructions from the above link, but when i try it out i get:

Code: Select all

A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
Invalid argument
"/home/pi/dead.letter" 1/11
. . . message not sent.
any ideas? :?:

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Basic Email setup

Thu Jul 19, 2012 1:03 am

The format I use to send my email is:

Code: Select all

"command" | mailx -v -A gmail -s "Insert Subject Here" destinationemail@email.com
Sometimes I substitute "command" with an echo. Mostly I just cat files though.

Code: Select all

cat myfile | mailx -v -A gmail -s "Insert Subject Here" destinationemail@email.com
To send to multiple email addresses just separate them with a space.

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Basic Email setup

Thu Jul 19, 2012 1:11 am

spud693 wrote:

Code: Select all

A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
Invalid argument
"/home/pi/dead.letter" 1/11
. . . message not sent.
Can you post your full email syntax. It appears that the From: field isn't parsing correctly. Mailx doesn't allow multiple From: addresses to try and prevent spammers from using it to spoof messages.

Are you using gmail as your provider?

What are the contents of your .mailrc file? (mask the important bits when posting)

spud693
Posts: 7
Joined: Sun Jul 08, 2012 9:53 pm

Re: Basic Email setup

Fri Jul 20, 2012 11:28 am

full email syntax:

Code: Select all

pi@raspberrypi:~$ echo | mailx -v -A gmail -s "test" myemail@yahoo.co.uk
A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
A Sender: field is required with multiple addresses in From: field.
Invalid argument
"/home/pi/dead.letter" 1/1
. . . message not sent.
i am indeed using Gmail,

and my .mailrc file is as follows:

Code: Select all

account gmail {
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=myemail@gmail.com
set smtp-auth-password=mypassword
set from="Spud693 Pi Server"
}
i didnt have a .mailrc file to start with so i created that one, i don't know if that file should be in a specific location, as present it's just in the root.

thanks!

fireraisr
Posts: 81
Joined: Wed Nov 23, 2011 2:34 am

Re: Basic Email setup

Fri Jul 20, 2012 6:39 pm

When you say it's in root, be sure you put it in ~/root and not just ~/

Try sending an email with the following line to the gmail address you put in the .mailrc file

Code: Select all

echo test | mailx -v -A gmail -s "This is a test" mailrc@gmail.com
You should get an email from yourself with the subject "This is a test" and "test" in the body.
Looking at your syntax, it's possible it doesn't like the empty echo statement.

underwood
Posts: 7
Joined: Tue Aug 07, 2012 5:48 pm

Re: Basic Email setup

Mon Oct 15, 2012 8:37 am

you have to change the set from in the .mailrc file to get it working from

set from="something"

to:

set from "somemail@adress.de (sendername)"

Return to “Beginners”