コード例 #1
0
ファイル: RelayMessageInfo.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
        /// <param name="sender">Senders email address.</param>
        /// <param name="recipient">Recipients email address.</param>
        /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
        /// <param name="notify">DSN notify condition.</param>
        /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
        /// <param name="date">Message date.</param>
        /// <param name="delayedDeliveryNotifySent">Specifies if delayed delivery notify has been sent.</param>
        /// <param name="hostEndPoint">Host end point where message must be sent. Value null means DNS is used to get message target host.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>sender</b> or <b>recipient</b> is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the arguments has invalid value.</exception>
        public RelayMessageInfo(string envelopeID,string sender,string recipient,string originalRecipient,SMTP_DSN_Notify notify,SMTP_DSN_Ret ret,DateTime date,bool delayedDeliveryNotifySent,HostEndPoint hostEndPoint)
        {
            if(sender == null){
                throw new ArgumentNullException("sender");
            }
            if(recipient == null){
                throw new ArgumentNullException("recipient");
            }
            if(recipient == ""){
                throw new ArgumentException("Argument 'recipient' value must be specified.");
            }

            m_EnvelopeID                = envelopeID;
            m_Sender                    = sender;
            m_Recipient                 = recipient;
            m_OriginalRecipient         = originalRecipient;
            m_DSN_Notify                = notify;
            m_DSN_Ret                   = ret;
            m_Date                      = date;
            m_DelayedDeliveryNotifySent = delayedDeliveryNotifySent;
            m_pHostEndPoint             = hostEndPoint;
        }
コード例 #2
0
ファイル: RelayServer.cs プロジェクト: dioptre/nkd
 /// <summary>
 /// Stores message for relay.
 /// </summary>
 /// <param name="id">Message ID. Guid value is suggested.</param>
 /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
 /// <param name="message">Message to store. Message will be readed from current position of stream.</param>
 /// <param name="targetHost">Target host or IP where to send message. This value can be null, then DNS MX o A record is used to deliver message.</param>
 /// <param name="sender">Sender address to report to target server.</param>
 /// <param name="to">Message recipient address.</param>
 /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
 /// <param name="notify">DSN notify condition.</param>
 /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
 /// <exception cref="ArgumentNullException">Is raised when <b>id</b>,<b>message</b> or <b>to</b> is null.</exception>
 /// <exception cref="ArgumentException">Is raised when any of the argumnets has invalid value.</exception>
 public void StoreRelayMessage(string id,String envelopeID,Stream message,HostEndPoint targetHost,string sender,string to,string originalRecipient,SMTP_DSN_Notify notify,SMTP_DSN_Ret ret)
 {
     StoreRelayMessage("Relay",id,envelopeID,DateTime.Now,message,targetHost,sender,to,originalRecipient,notify,ret);
 }
コード例 #3
0
ファイル: RelayServer.cs プロジェクト: dioptre/nkd
        /// <summary>
        /// Stores message for relay.
        /// </summary>
        /// <param name="queueName">Queue name where to store message.</param>
        /// <param name="id">Message ID. Guid value is suggested.</param>
        /// <param name="envelopeID">Envelope ID_(MAIL FROM: ENVID).</param>
        /// <param name="date">Message date.</param>
        /// <param name="message">Message to store. Message will be readed from current position of stream.</param>
        /// <param name="targetHost">Target host or IP where to send message. This value can be null, then DNS MX o A record is used to deliver message.</param>
        /// <param name="sender">Sender address to report to target server.</param>
        /// <param name="to">Message recipient address.</param>
        /// <param name="originalRecipient">Original recipient(RCPT TO: ORCPT).</param>
        /// <param name="notify">DSN notify condition.</param>
        /// <param name="ret">Specifies what parts of message are returned in DSN report.</param>
        /// <exception cref="ArgumentNullException">Is raised when <b>queueName</b>,<b>id</b>,<b>message</b> or <b>to</b> is null.</exception>
        /// <exception cref="ArgumentException">Is raised when any of the argumnets has invalid value.</exception>
        private void StoreRelayMessage(string queueName,string id,string envelopeID,DateTime date,Stream message,HostEndPoint targetHost,string sender,string to,string originalRecipient,SMTP_DSN_Notify notify,SMTP_DSN_Ret ret)
        {
            if(queueName == null){
                throw new ArgumentNullException("queueName");
            }
            if(queueName == ""){
                throw new ArgumentException("Argumnet 'queueName' value must be specified.");
            }
            if(id == null){
                throw new ArgumentNullException("id");
            }
            if(id == ""){
                throw new ArgumentException("Argument 'id' value must be specified.");
            }
            if(message == null){
                throw new ArgumentNullException("message");
            }
            if(to == null){
                throw new ArgumentNullException("to");
            }
            if(to == ""){
                throw new ArgumentException("Argument 'to' value must be specified.");
            }
					
			string path = m_pVirtualServer.MailStorePath + queueName;

			// Check if Directory exists, if not Create
			if(!Directory.Exists(path)){
				Directory.CreateDirectory(path);
			}

			// Create relay message.
			using(FileStream fs = File.Create(API_Utlis.PathFix(path + "\\" + id + ".eml"))){
                SCore.StreamCopy(message,fs);
                               
                // Create message info file for the specified relay message.
                RelayMessageInfo messageInfo = new RelayMessageInfo(
                    envelopeID,
                    sender,
                    to,
                    originalRecipient,
                    notify,
                    ret,
                    date,
                    false,
                    targetHost
                );
                File.WriteAllBytes(API_Utlis.PathFix(path + "\\" + id + ".info"),messageInfo.ToByte());
			}
        }