Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
c33ab622
Commit
c33ab622
authored
27 years ago
by
Fredrik Noring
Browse files
Options
Downloads
Patches
Plain Diff
The SMTP protocol is now made useful.
Rev: lib/modules/Protocols.pmod/SMTP.pmod:1.2
parent
d287e5aa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/Protocols.pmod/SMTP.pmod
+63
-5
63 additions, 5 deletions
lib/modules/Protocols.pmod/SMTP.pmod
with
63 additions
and
5 deletions
lib/modules/Protocols.pmod/SMTP.pmod
+
63
−
5
View file @
c33ab622
...
@@ -8,6 +8,48 @@ class client
...
@@ -8,6 +8,48 @@ class client
{
{
inherit protocol;
inherit protocol;
constant reply_codes =
([ 211:"System status, or system help reply",
214:"Help message",
220:"<host> Service ready",
221:"<host> Service closing transmission channel",
250:"Requested mail action okay, completed",
251:"User not local; will forward to <forward-path>",
354:"Start mail input; end with <CRLF>.<CRLF>",
421:"<host> Service not available, closing transmission channel "
"[This may be a reply to any command if the service knows it "
"must shut down]",
450:"Requested mail action not taken: mailbox unavailable "
"[E.g., mailbox busy]",
451:"Requested action aborted: local error in processing",
452:"Requested action not taken: insufficient system storage",
500:"Syntax error, command unrecognized "
"[This may include errors such as command line too long]",
501:"Syntax error in parameters or arguments",
502:"Command not implemented",
503:"Bad sequence of commands",
504:"Command parameter not implemented",
550:"Requested action not taken: mailbox unavailable "
"[E.g., mailbox not found, no access]",
551:"User not local; please try <forward-path>",
552:"Requested mail action aborted: exceeded storage allocation",
553:"Requested action not taken: mailbox name not allowed "
"[E.g., mailbox syntax incorrect]",
554:"Transaction failed" ]);
static private int cmd(string c, string|void comment)
{
int r = command(c);
switch(r) {
case 200..399:
break;
default:
throw(({"SMTP: "+c+"\n"+(comment?"SMTP: "+comment+"\n":"")+
"SMTP: "+reply_codes[r]+"\n", backtrace()}));
}
return r;
}
void create(void|string server)
void create(void|string server)
{
{
if(!server)
if(!server)
...
@@ -25,13 +67,29 @@ class client
...
@@ -25,13 +67,29 @@ class client
if(readreturncode()/100 != 2)
if(readreturncode()/100 != 2)
throw(({"Connection refused by SMTP server.\n",backtrace()}));
throw(({"Connection refused by SMTP server.\n",backtrace()}));
if(command("EHLO "+gethostname())/100 !=2)
if(catch(cmd("EHLO "+gethostname())))
if(command("HELO "+gethostname())/100 != 2)
cmd("HELO "+gethostname(), "greeting failed.");
throw(({"SMTP: greeting failed.\n",backtrace()}));
}
void send_message(string from, string *to, string body)
{
cmd("MAIL FROM:"+from);
foreach(to, string t)
cmd("RCPT TO:"+t);
cmd("DATA");
cmd(body+"\r\n.");
cmd("QUIT");
}
}
void s
end_message
(string
*
to, string
body
)
void s
imple_mail
(string to, string
subject, string from, string msg
)
{
{
// Not yet done
send_message(from, ({ to }),
(string)MIME.Message(0, (["mime-version":"1.0",
"subject":subject,
"from":from,
"to":to]),
({ MIME.Message(msg,
(["content-type":"text/plain;charset=iso-8859-1",
"content-transfer-encoding":"8bit"])) })));
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment