How deliver emails with sender's name

Sometimes i need to specify a name to show it when email is received.
Into “from” field i use this format:
addresser [email protected]

To do this i have to update smtp.rb file:
#C:\ruby\ruby-187p330\lib\ruby\1.8\net\smtp.rb

def mailfrom(from_addr)
  if $SAFE > 0
    raise SecurityError, 'tainted from_addr' if from_addr.tainted?
  end
  #getok("MAIL FROM:<#{from_addr}>") #before
  str = from_addr.to_s =~ /<.+>/ ? from_addr.to_s.match(/<.+>/).to_s

: “<#{from_addr}>” #marcomd
getok(“MAIL FROM:#{str}”) #marcomd
end

Marco M. wrote in post #978597:

Sometimes i need to specify a name to show it when email is received.
Into “from” field i use this format:
addresser [email protected]

To do this i have to update smtp.rb file:
#C:\ruby\ruby-187p330\lib\ruby\1.8\net\smtp.rb

def mailfrom(from_addr)
  if $SAFE > 0
    raise SecurityError, 'tainted from_addr' if from_addr.tainted?
  end
  #getok("MAIL FROM:<#{from_addr}>") #before
  str = from_addr.to_s =~ /<.+>/ ? from_addr.to_s.match(/<.+>/).to_s

: “<#{from_addr}>” #marcomd
getok(“MAIL FROM:#{str}”) #marcomd
end

mailfrom is for the SMTP envelope. You should only ever pass it a bare
E-mail address, never an RFC 2822 name-addr (comment plus E-mail address
in angle brackets).

In other words: your client code should strip this out before calling
send_message or open_message_stream, you don’t need to hack Net::SMTP to
do this.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs