Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MIME::Lite vs Net::SMTP

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I use MIME:Lite to send emails with attachments.

I've been getting the odd error, i've checked out the MIME::Lite module and from what I can tell it uses Net::SMTP for actually sending the email.

The thing is I cannot see anywhere in the Net:SMTP documentation how you use Net::SMTP for sending attachments, hence moving to MIME::Lite.

Can anyone help understanding how MIME::Lite uses Net:SMTP for sending attachments, so I can go back to using the Net::SMTP module for sending my emails and have more control over the connection to the mail server.

This is the section in the MIME::Lite module where it seems to use Net::SMTP and where I am getting my error
Code:
 ### Create SMTP client:
    require Net::SMTP;
    my $smtp = MIME::Lite::SMTP->new(@args)
        or Carp::croak("Failed to connect to mail server: $!\n");

the error I get is
Failed to connect to mail server: Bad file descriptor

would it be possible maybe if i changed the 'croak' to loop until it gets a connection, instead of erroring.

Or perhaps change the error message, with instructions to the user, or is it possible to send emails with attachments using Net::SMTP, as I was under the impression it wasn't and have not worked out how to do so if it is possible.

Any guidance on the best thing to do is appreciated.

Regards,
1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
you know , I answered the question myself!

rightly or wrongly, i've changed the module so it tries three times and then errors with the instructions I require.

here is my change....
Code:
my $smtp;
$smtp = MIME::Lite::SMTP->new(\@args)
or $smtp = MIME::Lite::SMTP->new(@args)
or $smtp = MIME::Lite::SMTP->new(@args)
or Carp::croak("Failed to connect to mail server: $!\n\nIMPORTANT: Please right mouse click this error, choose 'back' from the menu and submit the form again.\n\n");

hopefully this will be more user friendly for our members and gives a little fault tollerance with the three attempts before erroring.

Any thoughts?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I have been wrestling with MIME::Lite myself recently and it has been a nightmare.
I set it up on my own server in a matter of minutes wheras a client's ISP required numerous days of twiddling and gasp! module editing.
I originally wanted to use Sendmail but we need HTML content which I was led to understand, Sendmail cannot do.
I since discover that after going through MIME::Lite, date.pm, parse.pm and a number of others, the final send is being done by sendmail.
I will have another go when nurse says I can go home.



Keith
 
Hey Keith,

Sendmail is only on a *NIX environment. I used to use it when I had Linux hosting, but it doesn't exist for Windows.

Well the change to the module i've made , seems to be holding up so , I guess for me it's the best solution.

Nurse? are you ok, hope you get better soon.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
There is a module called Net::SMTP::Multipart that can be used to send attachments using the modules builtin methods.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
would you say it works better than MIME::Lite?


"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Net::SMTP::Multipart doesn't work.

It cannot handle HTML Emails and the PDF gets attached at some weird text file.

Back to the drwaing board!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
right i've edited MIME::Lite to the following...
Code:
    1 until $smtp = MIME::Lite::SMTP->new(\@args);

now it should keep trying until it gets a connection instead of croaking on me, and well if the mail server is down, the members will just have to kill their browser when they get fed up of waiting.

at least they won't keep bombarding me with emails about the 'Software Error', seings as our mail server providers refuse to take any responsibility for the failed connections.

maybe when they see my code hammering the server until it connects, they might then do something about it!

the ball is now in their court :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top