Sponsored Content
Top Forums Shell Programming and Scripting Getting error while sending mail via smtp Post 302424786 by zivsegal on Wednesday 26th of May 2010 09:49:47 AM
Old 05-26-2010
Getting error while sending mail via smtp

Hi All,
I used before a simple routine code in tcl to send mail.

Code:
package require smtp
package require mime
package require Tcl

proc send_simple_message {recipient email_server subject body} {

    set token [mime::initialize -canonical text/plain \
    -string $body]
    mime::setheader $token Subject $subject
    smtp::sendmessage $token \
    -recipients $recipient -servers $email_server -header [list From "FROM"] -header [list To "TO"]
    mime::finalize $token
}

send_simple_message someone@somewhere.com ENBMAIL01 "This is the subject." "This is the message."


I get errors about key-message id

Code:
key message-id not in header
    while executing
"error "key $mixed not in header""
    ("default" arm line 5)
    invoked from within
"switch -- $key {
        "" {
            set result ""
            foreach lower $state(lowerL) mixed $state(mixedL) {
                lappend result..."
    (procedure "::mime::getheader" line 7)
    invoked from within
"::mime::getheader $part ${message-idL} "
    invoked from within
"smtp::sendmessage $token  -recipients $recipient -servers $email_server -header [list From "FROM"] -header [list To "TO"]"
    (procedure "send_simple_message" line 7)
    invoked from within
"send_simple_message someone@somewhere.com ENBMAIL01 "This is the subject." "This is the message.""
    (file "test_mail.tcl" line 17)


Can someone help please,
Regards,
ZivSmilie

Last edited by pludi; 05-26-2010 at 11:31 AM.. Reason: code tags, please...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Error when sending mail attachment

I have been sending an email attachment from my unix box, but keep getting an error? All though the recipient still receives the email and attachment. Will this error cause problems in the future and how to I cure it? $ uuencode PReSvPRINTER.txt file | mailx -s "File" me@world.com uuencode:... (1 Reply)
Discussion started by: dbrundrett
1 Replies

2. HP-UX

Sending Error msg from HP-UX to E-mail address

Sometimes, for any reason, the UX System sends messages to /var/mail/root and/or to Error Log of the guardian. I'll appreciating if you help me to configure so that those messages are also sent to the System Administrator's e-mail address. Regards Gege (1 Reply)
Discussion started by: cgege
1 Replies

3. SuSE

How to configure Suse Enterprise Linux 9.0 for sending mails to smtp server...???

Hi All, I have a system running with Suse Enterprise Linux 9.0. xyz# uname -a Linux xyz 2.4.21-291-smp #1 SMP Tue May 24 14:07:45 UTC 2005 i686 unknown I would like to configure postfix on this system for sending mails as a root user using "mail" command to smtp server (Windows System)... (5 Replies)
Discussion started by: jumadhiya
5 Replies

4. Shell Programming and Scripting

sending mail error.. help

help i get this error when i sending a mail send-mail: fatal: open /etc/postfix/main.cf: No such file or directory Can't send mail: sendmail process failed this is my coding echo "$PRONAME is being restart" | mailxs "Subject:Process" "sally@$THISHOST" i wish to send this mail to my... (2 Replies)
Discussion started by: kkc
2 Replies

5. UNIX for Dummies Questions & Answers

sending mail via smtp

Hi Gururs, I have a process on a middelware (SAP XI) that is runnung on HP-UX. This Process is creating a flatfile. Now I want to call a script within the process that sends the created flatfile as attachment via Mail using a smpt-server. The script should have the following input parameters:... (2 Replies)
Discussion started by: elko.hasse
2 Replies

6. Shell Programming and Scripting

Sending Attachment using MIME::Lite and Net::SMTP

Hello, I'm a newbie perl scriptor and i'm trying to figure out why i can't send an email using MIME::Lite with Net::SMTP. I keep receiving the following error: SMTP MAIL command failed: 5.7.1 Helo invalid . at attach1.pl line 31 The error keeps coming from the very last line... (2 Replies)
Discussion started by: xmaverick
2 Replies

7. Shell Programming and Scripting

php code - Sending mail with external SMTP server

Here is the code: <?php //new function function loadini($path) { $fp = fopen($path, "r"); $fpcontents = fread($fp, filesize($path)); fclose($fp); return $fpcontents; } $to = "test@test.com"; $nameto = "notme"; $from = "test"; $namefrom = "Who From"; ... (0 Replies)
Discussion started by: galford
0 Replies

8. UNIX for Advanced & Expert Users

exim4 sending via multiple gmail smtp accounts

I need to send mail using different gmail smtp logins, depending on the from header. I can put the appropriate expression in dc_smarthost to generate the host, but I don't know how to specify the login id. The login id comes from passwd.client and is associated with the server name. According to... (1 Reply)
Discussion started by: Millwood
1 Replies

9. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

10. Shell Programming and Scripting

Configuring smtp settings and then sending the mail through shell script

I have make an menu in which first option is to start and second is to stop the services echo "Please enter the appropriate choice for doing the operations" echo " 1) STOP Services 2) START Services case $choice in 1) ... (1 Reply)
Discussion started by: punpun66
1 Replies
smtp(n) 							    smtp client 							   smtp(n)

__________________________________________________________________________________________________________________________________________________

NAME
smtp - Client-side tcl implementation of the smtp protocol SYNOPSIS
package require Tcl package require mime ?1.5.4? package require smtp ?1.4.5? ::smtp::sendmessage token option... _________________________________________________________________ DESCRIPTION
The smtp library package provides the client side of the Simple Mail Transfer Protocol (SMTP) (1) (2). ::smtp::sendmessage token option... This command sends the MIME part (see package mime) represented by token to an SMTP server. options is a list of options and their associated values. The recognized options are: -servers A list of SMTP servers. The default is localhost. -ports A list of SMTP ports. The default is 25. -client The name to use as our hostname when connecting to the server. By default this is either localhost if one of the servers is localhost, or is set to the string returned by info hostname. -queue Indicates that the SMTP server should be asked to queue the message for later processing. A boolean value. -atleastone Indicates that the SMTP server must find at least one recipient acceptable for the message to be sent. A boolean value. -originator A string containing an 822-style address specification. If present the header isn't examined for an originator address. -recipients A string containing one or more 822-style address specifications. If present the header isn't examined for recipient addresses). If the string contains more than one address they will be separated by commas. -header A list of keywords and their values (may occur zero or more times). -usetls This package supports the RFC 3207 TLS extension (3) by default provided the tls package is available. You can turn this off with this boolean option. -tlspolicy This option lets you specify a command to be called if an error occurs during TLS setup. The command is called with the SMTP code and diagnostic message appended. The command should return 'secure' or 'insecure' where insecure will cause the package to continue on the unencrypted channel. Returning 'secure' will cause the socket to be closed and the next server in the -servers list to be tried. -username -password If your SMTP server requires authentication (RFC 2554 (4)) before accepting mail you can use -username and -password to pro- vide your authentication details to the server. Currently this package supports DIGEST-MD5, CRAM-MD5, LOGIN and PLAIN authen- tication methods. The most secure method will be tried first and each method tried in turn until we are either authorized or we run out of methods. Note that if the server permits a TLS connection, then the authorization will occur after we begin using the secure channel. If the -originator option is not present, the originator address is taken from From (or Resent-From); similarly, if the -recipients option is not present, recipient addresses are taken from To, cc, and Bcc (or Resent-To, and so on). Note that the header key/values supplied by the -header option (not those present in the MIME part) are consulted. Regardless, header key/values are added to the outgoing message as necessary to ensure that a valid 822-style message is sent. The command returns a list indicating which recipients were unacceptable to the SMTP server. Each element of the list is another list, con- taining the address, an SMTP error code, and a textual diagnostic. Depending on the -atleastone option and the intended recipients, a non- empty list may still indicate that the message was accepted by the server. EXAMPLE
proc send_simple_message {recipient email_server subject body} { package require smtp package require mime set token [mime::initialize -canonical text/plain \ -string $body] mime::setheader $token Subject $subject smtp::sendmessage $token \ -recipients $recipient -servers $email_server mime::finalize $token } send_simple_message someone@somewhere.com localhost \ "This is the subject." "This is the message." REFERENCES
[1] Jonathan B. Postel, "SIMPLE MAIL TRANSFER PROTOCOL", RFC 821, August 1982. (http://www.rfc-editor.org/rfc/rfc821.txt) [2] J. Klensin, "Simple Mail Transfer Protocol", RFC 2821, April 2001. (http://www.rfc-editor.org/rfc/rfc2821.txt) [3] P. Hoffman, "SMTP Service Extension for Secure SMTP over Transport Layer Security", RFC 3207, February 2002. (http://www.rfc-edi- tor.org/rfc/rfc3207.txt) [4] J. Myers, "SMTP Service Extension for Authentication", RFC 2554, March 1999. (http://www.rfc-editor.org/rfc/rfc2554.txt) BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category smtp of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
ftp, http, mime, pop3 KEYWORDS
email, internet, mail, mime, net, rfc 2554, rfc 2821, rfc 3207, rfc 821, rfc 822, smtp, tls COPYRIGHT
Copyright (c) 1999-2000 Marshall T. Rose and others mime 1.4.5 smtp(n)
All times are GMT -4. The time now is 11:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy