Method: Net::IMAP#append

Defined in:
lib/net/imap.rb

#append(mailbox, message, flags = nil, date_time = nil) ⇒ Object

Sends a APPEND command to append the message to the end of the mailbox. The optional flags argument is an array of flags to initially passing to the new message. The optional date_time argument specifies the creation time to assign to the new message; it defaults to the current time. For example:

imap.append("inbox", "Subject: hello\nFrom: [email protected]\nTo: [email protected]\n\nhello world\n".gsub(/\n/, "\r\n"), [:Seen], Time.now)

A Net::IMAP::NoResponseError is raised if the mailbox does not exist (it is not created automatically), or if the flags, date_time, or message arguments contain errors.



600
601
602
603
604
605
606
607
608
# File 'lib/net/imap.rb', line 600

def append(mailbox, message, flags = nil, date_time = nil)
  args = []
  if flags
    args.push(flags)
  end
  args.push(date_time) if date_time
  args.push(Literal.new(message))
  send_command("APPEND", mailbox, *args)
end