Ilansu
18th April 2002, 17:44
Email from Baan script
Hello all
Im working on Baan IV c4 installed on Unix.
You probably discussed this in the past but
We have a customer service which handle the customers complains
When getting the complain we send the customer gets an email response.
I need to be able to send the email directly from a Baan script( choice.user.).
All the fields (from / to / subject / etc) can be field in a Baan session and copied to an ASCII file if need.
Does any one have the full solution without executing a VB program.
Can I do it all within the script or with some Unix commands?
Thanks
Ilan S
Han Brinkman
18th April 2002, 17:59
I know that if you put the entry mailhost in /etc/hosts on a Sun machine you can use the mailx functionality direct.
On others it could be a bit more complicated that you have to edit the sendmail.cf file in /etc in other to make the mailhost known.
Han
norwim
18th April 2002, 18:35
try to telnet to the mailhost on port 25.
If it responds, you need the following commands
HELO a_name
MAIL FROM: a_name
RCPT TO: email@adress_destination
(RCPT TO: another@adress_if_you_like)
DATA
all that
you type in now
will be
posted, until
there is a line with a
single dot
like this below
.
QUIT
If this experiment works, you can build a file which contains the data like above. Then cat this file to a pipe and telnet it to port 25
cat the_file | telnet IP_ADRESS_OF_MAILHOST 25
This works perfectly here, we use it to send emails out of Baan programs.
hth
Norber
NPRao
18th April 2002, 20:22
If you are on the HP Unix you can try this -
email.comm = "echo test|mailx -s " & subject & email.addr & filename
e = shell(email.comm, 0)
email.comm - email command
echo test - I dont know it expects some echo command at the beginning to make the mailx work.
-s - option for the subject
email.addr = email address of the recepient
filename - the file name/path in which the email is composed.
I hope it helps.
Neal Matthews
19th June 2002, 10:00
Hello I'm trying to use the following from an earlier post to send myself a simple e mail via telnet on port 25 of my SMTP server.
HELO a_name
MAIL FROM: a_name
RCPT TO: email@adress_destination
DATA
test
.
QUIT
cat the_file | telnet IP_ADRESS_OF_MAILHOST 25
This works perfectly in the telnet session but when I try it from cat the_file it doesn't work. The system just returns "connection closed by foreign host" in repsonse to the quit which is the expected output but mail the is not being sent.
Can anybody with a little more unix knowhow suggest how I can track this problem or suggest any further testing.
I am using the telnet method as opposed to mailx as my unix server is not the mail server and I am attempting to get my mail to be sent from a notes server.
Is there any way that you can specify the ip address of the mail server when using mailx ?
Regards
Neal Matthews
Intier Automotive - IT Support Analyst
mark_h
19th June 2002, 14:33
I am not an expert, but couldn't you put the IP Address in the /etc/hosts file like Han suggested. Then you could use the mailx command directly. I am not an expert on getting mailx to work, but that was all I did on one of our unix boxes.
Below is a test I did. I needed to find out if I could page people from Baan. It works on our sun system. Just remember it was just a limited test.
Good Luck!
Mark
function extern tuddc.dllfile.alpha_page(domain tcmcs.str10 pager.number,
domain tcmcs.str20 subject,
domain tcmcs.str132 msg)
{
string temp.file(1024),cmd(1024)
long status,f1
| Create temporary file to copy the PC file to
temp.file = creat.tmp.file$(bse.tmp.dir$())
temp.file = strip$(temp.file)
| Open Server file for processing.
f1 = seq.open(temp.file,"w")
seq.puts(msg,f1)
status = seq.close(f1)
cmd = sprintf$("-c %smailx %s@epage.arch.com -s%s<%s%s" ,chr$(34),str
ip$(pager.number),subject,temp.file,chr$(34))
status = run.prog("sh",cmd,RP_WAIT)
seq.unlink(temp.file)
}
Neal Matthews
19th June 2002, 15:17
Thanks Mark,
I went back and read Han's post properly.
I have been editing the hosts file but not with the mailhost entry.
I've now got mailx working properly so I just need to fiddle around with it a bit.
Regards
Neal Matthews
Intier Automotive - IT Support Analyst
DSonifer
28th July 2008, 20:08
I know this is an old post. Did you ever get mailx to work with input a file rather than interactively entering data? I am stuck on that spot.
Running HPUX 11.00, also trying from Linux Redhat Enterprise Edition.
günther
29th July 2008, 08:57
Hi,
I would suggest the following tests:
1. cat /etc/passwd | mailx -s subject your_local_unix_user
You should receive that mail on unix; use "mailx" to read it.
2. cat /etc/passwd | mailx -s subject your_offical_mail_account
You sould now receive that mail as usual (windows?). If not: use "mailq" on your unix box to check, if the mail is not buffered there. Check your /var/adm/syslog/mail.log file.
If anything fails: The minimum is to setup a "smart relay host" (see DS in /etc/mail/sendmail.cf); enter the fully qualified name of your smtp server. Remember to restart sendmail (/sbin/init.d/sendmail stop; /sbin/init.d/sendmail start) after changes to that file.
Günther
Neal Matthews
31st July 2008, 10:23
Hello,
This is the command I most commonly use within script files generally called by the Baan job queue. There should be several similar examples on the board which explain the use of uuencode.
uuencode /triappiv/bse/home/tools/test /triappiv/bse/home/tools/test.html | mailx -s "SUBJECT" -r sender@test.co.uk receiver@test.com
Cheers Neal
DSonifer
31st July 2008, 18:10
I can send an email using telnet to Port 25 of my email sever (Microsoft Exchange); see below. At least sometimes I can. I succeeded once today but am unable to successfully receive an email after doing another telnet command.
Just in case this is important, we are running HP Unix version 11.00.
/# telnet serv10.conwed.conwedplastics.com 25
Trying...
Connected to serv10.conwed.conwedplastics.com.
Escape character is '^]'.
220 serv10.conwed.conwedplastics.com Microsoft ESMTP MAIL Service, Version: 6.0.
3790.3959 ready at Thu, 31 Jul 2008 08:52:52 -0500
helo dks
250 serv10.conwed.conwedplastics.com Hello [140.140.100.16]
mail from: dks
250 2.1.0 dks@conwedplastics.com....Sender OK
rcpt to: dennis.sonifer@conwedplastics.com
250 2.1.5 dennis.sonifer@conwedplastics.com
data
354 Start mail input; end with <CRLF>.<CRLF>
line 1
line 2 NOTE: here I pressed <ctl>d, then entered the 2 lines with just periods
.
.
250 2.6.0 <SERV10ek91HbJggVZVE00000011@serv10.conwed.conwedplastics.com> Queued
mail for delivery
quit
221 2.0.0 serv10.conwed.conwedplastics.com Service closing transmission channel
Connection closed by foreign host.
This is the email I received via Exchange & Outlook
-----Original Message-----
From: dks@conwedplastics.com [mailto:dks@conwedplastics.com]
Sent: Thursday, July 31, 2008 9:50 AM
Subject:
line 1
line 2
end of file next
.
This is the same entry as what succeeded earlier but now nothing from Exchange & Outlook
/var/adm/syslog# telnet mailhost 25
Trying...
Connected to mailhost.
Escape character is '^]'.
220 serv10.conwed.conwedplastics.com Microsoft ESMTP MAIL Service, Version: 6.0.
3790.3959 ready at Thu, 31 Jul 2008 09:51:29 -0500
helo dks
250 serv10.conwed.conwedplastics.com Hello [140.140.100.16]
mail from: dks
250 2.1.0 dks@conwedplastics.com....Sender OK
rcpt to: dennis.sonifer@conwedplastics.com
250 2.1.5 dennis.sonifer@conwedplastics.com
data
354 Start mail input; end with <CRLF>.<CRLF>
test line 1
test line 2 NOTE: I also tried entering <ctl>d and another line with "." but made no difference.
250 2.6.0 <SERV10FIROy6h9O8bLY00000014@serv10.conwed.conwedplastics.com> Queued
mail for delivery
quit
221 2.0.0 serv10.conwed.conwedplastics.com Service closing transmission channel
Connection closed by foreign host.
/var/adm/syslog#
I don't know why there is still a domain error. Here is sendmail.cf file with Dj macro set and Smart Relay value. When I enter command sendmail -bt it shows that macros $m and $j are set to conwedplastics.com
# my official domain name
# ... define this only if sendmail cannot automatically determine your domain
# DKS 29 Jul 2008: added fully qualified domain name
Dj$w.conwedplastics.com # NOTE: I also tried Dj$w.conwed.conwedplastics.com and Dj$w.conwed1.conwed.conwedplastics.com
# "Smart" relay host (may be null)
#DS
DS serv10.conwed.conwedplastics.com
Jul 31 09:39:04 conwed1 /sbin/init.d/sendmail[15907]: #### rebooted ####
Jul 31 09:39:04 conwed1 sendmail[15915]: unable to qualify my own domain name (c
onwed1) -- using short name
Jul 31 09:39:04 conwed1 sendmail[15915]: be sure to set domain name in Dj macro
in sendmail.cf
Jul 31 09:39:04 conwed1 sendmail[15915]: alias database /etc/mail/aliases rebuil
t by root
Jul 31 09:39:04 conwed1 sendmail[15915]: /etc/mail/aliases: 7 aliases, longest 9
bytes, 88 bytes total
Jul 31 09:39:04 conwed1 sendmail[15916]: unable to qualify my own domain name (c
onwed1) -- using short name
Jul 31 09:39:04 conwed1 sendmail[15916]: be sure to set domain name in Dj macro
in sendmail.cf
Jul 31 09:39:04 conwed1 sendmail[15917]: starting daemon (8.9.3 (PHNE_29773)): SMTP+queueing@00:30:00
My /etc/hosts also have the domain name. Also 'mailhost' defined so I could use mailx command.
# See the hosts(4) manual page for more information.
# Note: The entries cannot be preceded by a space.
# The format described in this file is the correct format.
# The original Berkeley manual page contains an error in
# the format description.
#
140.140.100.16 conwed1 # L2000 HP Server
140.140.100.16 conwed1.conwed.conwedplastics.com # Fully Qualified Domain Name
140.140.1.85 serv10.conwed.conwedplastics.com # MS Exchange Server
140.140.1.85 mailhost # MS Exchange Server
127.0.0.1 localhost loopback
günther
1st August 2008, 09:30
Your /etc/hosts is wrong. It must loook like
140.140.100.16 conwed1 conwed1.conwed.conwedplastics.com # L2000 HP Server
140.140.1.85 mailhost serv10.conwed.conwedplastics.com # MS Exchange Server
127.0.0.1 localhost loopback
Only one line per IP address, followed by a list of host names and aliases.
When you then restart sendmail (/sbin/init.d/sendmail stop, /sbin/init.d/sendmail start), is there still the "unable to qualify my own domain name" problem?
Günther
DSonifer
1st August 2008, 17:14
I updated the /etc/hosts file as you suggested. Then stopped and restarted sendmail. I then tried the following command (cat /home/dks/x.txt | mailx -s "Testing" dennis.sonifer@conwedplastics.com -- where x.txt consists of 2 lines
Line 1
Line 2
, but still getting a 'transient parse error'; see mail.log text below:
Aug 1 09:02:43 conwed1 /sbin/init.d/sendmail[27634]: #### rebooted ####
Aug 1 09:02:43 conwed1 sendmail[27657]: alias database /etc/mail/aliases rebuil
t by root
Aug 1 09:02:43 conwed1 sendmail[27657]: /etc/mail/aliases: 7 aliases, longest 9
bytes, 88 bytes total
Aug 1 09:02:44 conwed1 sendmail[27666]: starting daemon (8.9.3 (PHNE_29773)): S
MTP+queueing@00:30:00
Aug 1 09:04:37 conwed1 sendmail[28281]: JAA28281: to=dennis.sonifer@conwedplast
ics.com, delay=00:00:00, mailer=relay, relay=serv10.conwed.conwedplastics.com, s
tat=Transient parse error -- message queued for future delivery
Aug 1 09:04:37 conwed1 sendmail[28281]: JAA28281: from=root, size=179, class=0,
pri=30179, nrcpts=1, msgid=<200808011404.JAA28281@conwed1.conwed.conwedplastics
.com>, relay=root@localhost
Aug 1 09:04:37 conwed1 sendmail[28281]: JAA28281: to=dennis.sonifer@conwedplast
ics.com, delay=00:00:00, mailer=relay, stat=queued
DSonifer
1st August 2008, 17:53
I updated the Domain Name Servers, adding the 2 in our network, stopped/restarted sendmail. No more reference to not being able to determine domain name.
I was still getting transient parse errors. I updated the DNS entries using SAM and that error disappeared. And now I have successfully used the mailx command to send a file
günther
4th August 2008, 08:26
Hi,
congratulations! Now since your sendmail works, you could do some useful things:
edit /etc/aliases and add a line that maps your unix user to your full email account; let's say you login as 'dsonifer' on the unix box. The you could add a line
dsonifer : dennis.sonifer@conwedplastics.com
Then run 'newaliases' and restart sendmail. No you can run 'mailx dsonifer' and you get that mail to your outlook(?) account.
you can also map users to other users to get their mail forwarded
root : dsonifer
you can also build groups or mailing lists, e.g.
joberrors : user1, user2, user3
Funny, isn't it?
Günther
günther
4th August 2008, 08:41
Last but not least, back to your original question:
You can also use 'sendmail' directly to send mail. That is a bit more "low-level" than mailx (or elm), but you have much more control.
Here is an example:
/usr/sbin/sendmail [-fsomebody@conwedplastics.com] somebody@customer.com <FILE
with FILE:
Subject: Subject generated 02.08.2008 09:11:41
Date: Sat, 02 Aug 2008 09:11:41 +0200
X-Priority: 1
X-MSMail-Priority: High
To: somebody@customer.com
Reply-To: <something>
Errors-To: <something>
Return-Receipt-To: <something>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="boundary-20080802-091141"
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
--boundary-20080802-091141
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Dear ladies and gentlemen,
...
Kind regards
--boundary-20080802-091141
Content-Type: application/octet-stream; name="file.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="file.pdf"
Content-Description: Sample file
<Here starts the uuencoded or base64 coded part>
--boundary-20080802-091141--
Hope you get the idea. You can find information on the keyword MIME. Please note that you must not use text files directly as a mime part because of internal limitations of mail (only 70 chars per line! ony US-ASCII charset!).
Günther
Arely CG
7th April 2010, 18:18
If i need an attachment?
I have....
mailx -r someone@any.com -s Subject:'" & str$(campo) & " destiny@any.com < /xxxx/xxxx/out.mail
and i can´t concat the string, Someone can help me?
mark_h
7th April 2010, 19:43
Are you building this in a command string within a baan session?
example:
cmd = "mailx -s 'PS/Baan Employee Errors (Automated Email)' " &
strip$(email.addr) & "<" & temp.file
You need to get the quotes correct around the mailx command.
vipulb
8th April 2010, 07:07
Make a device new device type.
günther
8th April 2010, 07:55
If i need an attachment?
Have a look at my example. It shows you an attachment (file.pdf) to a regular mail (Dear ladies and genlemen, ... Kind regards).
Günther