CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
send an email with a script

 



gerble1000
User

Jul 18, 2012, 8:15 AM

Post #1 of 19 (3653 views)
send an email with a script Can't Post

i could do with making a simple email sending script.
i have played with examples online and yet to figure out why it aint working.
tried mime::lite
if i cannot just use directly could i use a specified hotmail account and if so how would i incorporate this into the script

here is my non working example



Code
 
use strict;
use warnings;
use MIME::Lite::TT::HTML;


my %params;

$params{first_name} = 'Frank';
$params{last_name} = 'Wiles';
$params{amt_due} = '24.99';

my %options;
$options{INCLUDE_PATH} = 'templates';

my $msg = MIME::Lite::TT::HTML->new(
From => 'admin@example.com',
To => 'destinationemail@hotmail.co.uk',
Subject => 'Your recent purchase',
Template => {
text => 'test.txt.tt',
html => 'test.html.tt',
},
TmplOptions => \%options,
TmplParams => \%params,
);

$msg->send('smtp','some.host', Port => 12345 );
print "message sent";



FishMonger
Veteran / Moderator

Jul 18, 2012, 10:09 AM

Post #2 of 19 (3648 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

Have you tried enabling debug?

$msg->send('smtp','some.host', Port => 12345, Debug => 1 );


gerble1000
User

Jul 18, 2012, 10:14 AM

Post #3 of 19 (3646 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

that gave no extra info?
where would i put my hotmail username and password if i was to use that service


gerble1000
User

Jul 18, 2012, 10:16 AM

Post #4 of 19 (3645 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

the error i am getting is this
SMTP Failed to connect to mail server: Invalid argument


FishMonger
Veteran / Moderator

Jul 18, 2012, 10:19 AM

Post #5 of 19 (3644 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

$msg->send('smtp','some.host', AuthUser=>$user, AuthPass=>$pass, Debug => 1);


gerble1000
User

Jul 18, 2012, 10:55 AM

Post #6 of 19 (3642 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

i am still getting this error message
SMTP Failed to connect to mail server: Invalid argument
with this code

Code
$msg->send('smtp','smtp.live.com ', AuthUser=>$user, AuthPass=>$pass,Port => 587 , Debug => 1);



FishMonger
Veteran / Moderator

Jul 18, 2012, 12:10 PM

Post #7 of 19 (3640 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

Is that the complete and exact error message?

Does it say which arg is invalid?


gerble1000
User

Jul 18, 2012, 12:17 PM

Post #8 of 19 (3638 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

just points to this line
$msg->send('smtp','smtp.live.com ', AuthUser=>$user, AuthPass=>$pass,Port => 587 , Debug => 1);


FishMonger
Veteran / Moderator

Jul 18, 2012, 12:21 PM

Post #9 of 19 (3637 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

The only problem I see is that you have a space at the end of the smtp hostname.

Did you assign values to the $user and $pass vars?


gerble1000
User

Jul 18, 2012, 12:24 PM

Post #10 of 19 (3636 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

yes i asigned values but i included an @ sign does this need a /@

myemail@hotmail.com
myemail/@hotmail.com


FishMonger
Veteran / Moderator

Jul 18, 2012, 12:30 PM

Post #11 of 19 (3634 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

If you used double quotes, then you will need to escape the @ symbol, but if you use single quotes, then you won't need to escape it.


(This post was edited by FishMonger on Jul 18, 2012, 12:30 PM)


gerble1000
User

Jul 18, 2012, 12:30 PM

Post #12 of 19 (3632 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

ok i am getting this error message now
SMTP auth() command not supported on smtp.live.com


gerble1000
User

Jul 18, 2012, 12:36 PM

Post #13 of 19 (3628 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

when i remove the auth i get this error
SMTP mail() command failed:
5.7.0 Must issue a STARTTLS command first


FishMonger
Veteran / Moderator

Jul 18, 2012, 12:50 PM

Post #14 of 19 (3625 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

I don't work with hotmail, so I'm not sure what they require, but are you sure you need to use port 587? That's for encrypted email, and I'm not sure if the module supports it. Try using port 25, which is the default.

You could try adding STARTTLS => 1 but I doubt that it will work.


gerble1000
User

Jul 18, 2012, 1:19 PM

Post #15 of 19 (3621 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

changing the port made no difference and that startttl done nothing either.
so you think its just the hotmail stopping it then


FishMonger
Veteran / Moderator

Jul 18, 2012, 1:27 PM

Post #16 of 19 (3620 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

Yes, they could be blocking it, or require additional parameters. Since I've never worked with hotmail, you may want to post a question on one of the other forums to see if anyone else has a solution.


gerble1000
User

Jul 18, 2012, 1:29 PM

Post #17 of 19 (3617 views)
Re: [FishMonger] send an email with a script [In reply to] Can't Post

ok well thankyou anyway. i will have a hunt around and get back to this post ;)


lukdk
Novice

Jul 24, 2012, 2:53 PM

Post #18 of 19 (3455 views)
Re: [gerble1000] send an email with a script [In reply to] Can't Post

just an out of the box idea... but in my case, i don't have to use the SMTP server from hotmail, i would just use my own ISP's SMTP, without auth.

Lots of providers let you send mails from other domains, using their smtp server. (the main reason why an SMTP mail is not safe, and could be from anyone pretending to be you)
So just try to use the SMTP from the ISP your computer which is running the script is connected to.


(This post was edited by lukdk on Jul 24, 2012, 2:55 PM)


gerble1000
User

Aug 10, 2012, 6:37 AM

Post #19 of 19 (3106 views)
Re: [lukdk] send an email with a script [In reply to] Can't Post

could you provide me with a script and tell me how to set it up please

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives