![]() |
Sending Mails with Perl using Net::SMTP
On 15th January, 2007
|
Recent Articles
Similar Articles
Code: Perl
|
|
|
#2 |
|
Newbie Member
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
I had some trouble getting net:SMTP working on a server that required smtp authentication on a windows web server using cgi perl. We finally got it working, so I wanted to share the code somewhere: Code: PERL
|
|
|
|
|
|
#3 |
|
Team Leader
![]() |
Re: Sending Mails with Perl using Net::SMTP
Normally SMTP uses PLAIN authentication, why are you base64 encoding it?? There are many authentication mechanisms!
__________________
Vote for the Most Entertaining Member of 2008 To err is human,to detect is divine! |
|
|
|
|
|
#4 |
|
Newbie Member
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
Only because PLAIN didn't work, and this did. I'm open to suggestions. |
|
|
|
|
|
#5 |
|
Team Leader
![]() |
Re: Sending Mails with Perl using Net::SMTP
There a method auth ( USERNAME, PASSWORD ), try using this instead, it'll automatically select the appropriate authentication mechanism!
__________________
Vote for the Most Entertaining Member of 2008 To err is human,to detect is divine! |
|
|
|
|
|
#6 |
|
Newbie Member
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
That's what we thought, but after working on it that way for a day we just still couldn't get it to work. I am not an expert on CGI/Perl, so I was working with someone who was - I apologize if I don't explain very well, but here is what I got out of it: I'm sorry I didn't write down the exact error we started with, but it might have been the 535 Incorrect authentication data Finally after a day of struggling, we decided to try AUTH LOGIN instead of PLAIN or the other option. That didn't work at first, so we tried encoding the username & password. Suddenly, it worked. It seemed to need to wait for a response also, so that's why the $smtp->response(); was added. Does that even make sense??? |
|
|
|
|
|
#7 |
|
Newbie Member
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
This code only seems to work. In case you have a negative response from the server, eg. $smtp->response() will still return ok
|
|
|
|
|
|
#8 |
|
Go4Expert Member
Join Date: Feb 2009
Location: UK
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
Hello pardeep Good article, There are a number of ways to tell Perl scripts where to send email. Here is the script. Below the code is a discussion of it's various elements. #!/usr/bin/perl $Mailer = '/sbin/sendmail -t'; $Email = $ENV{QUERY_STRING}; open MAIL,"|$Mailer"; print MAIL <<THE_EMAIL; From: me\@mydomain.com To: $Email Subject: My first mailer This is the auto-response email sent when I launched the script with a "?$Email" following the script's URL. Yeah! THE_EMAIL close MAIL; print "Content-type: text/html\n\n"; print '<center>T H A N K Y O U !</center>'; # end of script The first line of the script must have the location of Perl on your server. |
|
|
|
|
|
#9 |
|
Go4Expert Member
Join Date: Apr 2009
Posts: 35
Thanks: 4
Thanked 0 Times in 0 Posts
Rep Power: 0 ![]() |
Re: Sending Mails with Perl using Net::SMTP
Today mostly SMTP server require SSL authntication so u will have to use Net::SMTP_auth instead of Net::SMTP .It works fine i tested it if any body has problem about it then tell me ,i will post smtp server name(obivsly free h yaar) nd script that works fine, till then happy progqaming |
|
|
|
![]() |
|
| Currently Active Users Reading This Article: 1 (0 members and 1 guests) | |
| Article Tools | Search this Article |
| Display Modes | |
| Bookmarks | |
|
|
|
|||||||||||||||||||||||||||||||||||||