HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2011
1115
syunhspsock.dllを使用してメールをsmtp送信1未解決


syun

リンク

2011/11/15(Tue) 03:29:25|NO.43017

hspsock.dllを使用してsmtpプロトコルでメールを送るということについてですが、
テキストの内容を読み取って送るテストをしてみたのですが、なぜかメールの内容が空に?
なってしまうのです。なぜかわかる方はいませんか?一応ソースがあるので(他サイトから)
乗せます。




notesel a
noteload dirinfo($10000)\\test\\test.txt" 



/****************/
/* 定数定義部 */
/****************/
#define SMTPSERVER "smtp.mail.yahoo.co.jp" ;SMTPサーバ
#define SMTPPORT 587 ;SMTPポート
#define BUFSIZE 1024 ;受信バッファサイズ
#define BASE64USER "Zm9v" ;Base64エンコード済みユーザー名
#define BASE64PASS "YmFy" ;Base64エンコード済みパスワード
#define FROM "foo@hogehoge.com" ;送信元アドレス
#define TO "bar@hogehoge.com" ;送信先アドレス
#define SUBJECT "It's TestMail" ;サブジェクト
#define MAINDATA a ;本文

/**********************/
/* 関数・命令定義部 */
/**********************/
#module
#include "hspsock.as"

/* ConnectServer - サーバへ接続します */
#defcfunc ConnectServer int Sock, str Server, int Port
sockopen Sock,Server,Port
if stat!=0 : mes "接続失敗" : return 1 ;エラー処理
return 0

/* CloseSocket - ソケットを閉じます */
#deffunc CloseSocket int Sock
sockclose Sock
return

/* SendCommand - 指定文字列を送信し、応答コードをチェックします */
#defcfunc SendCommand int Sock, str SendData, var ReceiveData, int BufSize, str Response
sockput SendData,Sock ;送信データを送信
if stat!=0 : return 1

repeat
wait 1 ;少し待つ
sockcheck Sock ;受信できるデータがあれば
if stat==0 : break ;ループを抜ける
loop

ReceiveData=""
sockget ReceiveData,BufSize,Sock ;そして受信
if stat!=0 : return 1

StatCode=strmid(ReceiveData,0,3) ;受信データの最初から3文字切り出し
if StatCode!=Response : return 1 ;Responseを比較

return 0

/* SendDataPart - DATAコマンド後のデータパートを送信します */
#defcfunc SendDataPart int Sock,str DataPart
sockput DataPart,Sock
if stat!=0 : return 1
sockput "\n.\n",Sock
if stat!=0 : return 1
return 0

#global


/************************/
/* メインスクリプト部 */
/*************************/

/* ReceiveData変数を確保 */
sdim ReceiveData,BUFSIZE

/* 終了フラグ */
AbnormalFlag=1

/* サーバへ接続 */
if ConnectServer(0,SMTPSERVER,SMTPPORT)==1 : goto *exit

/* 接続後応答を受信 */
if SendCommand(0,"",ReceiveData,BUFSIZE,"220")==1 : goto *exit
mes ReceiveData

/* EHLOコマンドを送信 */
if SendCommand(0,"EHLO "+SMTPSERVER+"\n",ReceiveData,BUFSIZE,"250")==1 : goto *exit
mes ReceiveData

/* AUTH LOGINコマンドを送信 */
if SendCommand(0,"AUTH LOGIN\n",ReceiveData,BUFSIZE,"334")==1 : goto *exit
mes ReceiveData

/* ユーザー名を送信 */
if SendCommand(0,BASE64USER+"\n",ReceiveData,BUFSIZE,"334")==1 : goto *exit
mes ReceiveData

/* パスワードを送信 */
if SendCommand(0,BASE64PASS+"\n",ReceiveData,BUFSIZE,"235")==1 : goto *exit
mes ReceiveData

/* MAIL FROMコマンドを送信 */
if SendCommand(0,"MAIL FROM:"+FROM+"\n",ReceiveData,BUFSIZE,"250")==1 : goto *exit
mes ReceiveData

/* RCPT TOコマンドを送信 */
if SendCommand(0,"RCPT TO:"+TO+"\n",ReceiveData,BUFSIZE,"250")==1 : goto *exit
mes ReceiveData

/* DATAコマンドを送信 */
if SendCommand(0,"DATA\n",ReceiveData,BUFSIZE,"354")==1 : goto *exit
mes ReceiveData

/* 本文送信 */
data ="From: "+FROM+"\n"
data+="To: "+TO+"\n"
data+="Subject: "+SUBJECT+"\n"
data+="Content-Type: text/plain; charset=Shift_JIS\n"
data+="Content-Transfer-Encoding: 8bit\n\n" ;ここまでヘッダ
data+=MAINDATA ;本文
if SendDataPart(0,data)==1 : goto *exit

/* QUITコマンドを送信 */
if SendCommand(0,"QUIT\n",ReceiveData,BUFSIZE,"250")==1 : goto *exit
mes ReceiveData

AbnormalFlag=0

/* エラーが起きたらここへ飛ばす */
*exit
CloseSocket 0
if AbnormalFlag==1 : mes "異常終了" : else : mes "通常終了



この記事に返信する


skyblue

リンク

2011/11/15(Tue) 07:15:08|NO.43018

半角の<pre>〜<pre>で囲みましょう
>noteload dirinfo($10000)\\test\\test.txt"
noteload dirinfo($10000)+"\\test\\test.txt"に変更でどうですか?



ONION software Copyright 1997-2023(c) All rights reserved.