[ic] email-raw usertag broken for Net::SMTP FIX
peter at pajamian.dhs.org
Sun May 1 02:23:00 EDT 2005
On 04/30/05 20:04, Mike Heins wrote:
> Quoting Peter (peter at pajamian.dhs.org):
>>On 04/30/05 07:50, Mike Heins wrote:
>>>Quoting Peter (peter at pajamian.dhs.org):
>>>>Well technically it's not broken because it does specify in the docs
>>>>that it uses sendmail. But if you use Net::SMTP for sending out emails
>>>>then no emails will be sent via this tag. I've modified the tag to work
>>>>with Net::SMTP as well (feel free to tweak and change or whatever) and
>>>>would like to submit this to be included in future versions of
>>>>interchange. Here's a patch to IC 5.2.
>>>>Note that in theory you could eliminate all bbut the middle clause to
>>>>the if/elsif/else statement, but i wanted to keep the original
>>>>functionality of being able to send directly to sendmail rather than
>>>>simulate it through the send_mail function.
>>>This seems like a useful idea. It just so happens that I have just
>>>enhanced the [email ...] tag to do attachments with MIME::Lite,
>>>and haven't yet committed it. It uses [email-raw ..] to send,
>>>so I can put both in at the same time.
>>One thing I failed to mention before is that my patch fails to account
>>for the possibility of folded headers. I didn't think too much of it
>>because I don't anticipate anyone using the email-raw tag to send emails
>>out with folded headers, but if you want to make it work with then an
>>additional regexp to unfold them should fix it. Something like the
>>following before the split line should do it:
>>$headers =~ s/\r?\n([ \t])/$1/s;
> It would seem to make sense to account for it. Can't we do so simply by
> joining the @header array with a \n without stripping the headers
> in send_mail?
I never bothered to look fully into the details of how send_mail works
with Net::SMTP. That said...
When I patched email-raw I looked at send_mail to see how to use it and
it checks the first arg to see if it's a ref and if it is it assumes
that the first arg is an array ref of all the headers and the second arg
the email body. If the first arg is not a ref then it is assumed to be
the To: recipient for the email. so by joining them as yuou suggest
would just make send_mail assume that all those headers are the
recipient and won't work. If you want to hack up send_mail to work
differently then be my guest, but i would want to caution against doing
so in a way that might break existing functionality.
One possible way to fix it would be to have it be able to parse multiple
headers out of just one element of the head array, so you could call it
$ok = send_mail([$headers],$body);
$ok = send_mail([$headers,$extra_headers],$body);
...then the existing functionality of send_mail would be preserved and
any custom usertags that rely on it wouldn't break.
> One reason I had been avoiding all this is that the send_mail routine
> is really an incredibly bad hack. It is some of the original code
> in Vend 0.2, mangled year after year to wedge in more stuff. I had
> always imagined I was going to make it reasonable, but instead we
> ended up with send_mail, mail.coretag, email.coretag, email-raw.coretag,
Sheesh, I never realised there was a mail tag as well. Maybe the email
and email-raw usertags should just be rewritten as stubs of the mail tag
since it seems to combine the functionality of both.
I haven't checked yet, but can I assume that the mail tag works fine
More information about the interchange-users