How deliver emails with sender's name

M

Marco Mastrodonato

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
 
B

Brian Candler

Marco Mastrodonato 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top