Jay Roy
asked on
send email on button click
hi guys
I am using Flex UI with java in the backend using spring Blazeds integration.
When i click on a flex button i need to submit an email with subject and some message body. If anyone has worked on such a requirment, I would greatly appreciate any help.
thanks.
I am using Flex UI with java in the backend using spring Blazeds integration.
When i click on a flex button i need to submit an email with subject and some message body. If anyone has worked on such a requirment, I would greatly appreciate any help.
thanks.
ASKER
let me look..thx
I have a button
<mx:Button click= what function should i call ? />
also, can you tell me what connection information i need to send the mail. I am working in a small company, for testing i can use my yahoo email, but i think eventually i will need the mail server information from my company?
thanks for help.
I have a button
<mx:Button click= what function should i call ? />
also, can you tell me what connection information i need to send the mail. I am working in a small company, for testing i can use my yahoo email, but i think eventually i will need the mail server information from my company?
thanks for help.
private function send():void{
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.yourcompanydomain.co m';
var Username:String ='mail@yourcompanydomain.c om';
var Password:String = 'xxxxxxx';
var frmLbl:String = 'SMTP Mailer <mail@yourcompanydomain.co m>';
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
smtp.Port = 25;
smtp.connect(smtp.Host, smtp.Port );
smtp.recepient = "mail@yourcompanydomain.co m";
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
}
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.yourcompanydomain.co
var Username:String ='mail@yourcompanydomain.c
var Password:String = 'xxxxxxx';
var frmLbl:String = 'SMTP Mailer <mail@yourcompanydomain.co
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
smtp.Port = 25;
smtp.connect(smtp.Host, smtp.Port );
smtp.recepient = "mail@yourcompanydomain.co
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
}
ASKER
great!
so if my company email is jay.ronda@benziga.com (company domain is benziga.com)
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.benziga.com';
var Username:String ='jay.ronda@benziga.com';
var Password:String = 'xxxxxxx'; --my password
var frmLbl:String = 'SMTP Mailer <jay.ronda@benziga.com>'; --is this right ?
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
smtp.Port = 25; -- will this change for my company?
smtp.connect(smtp.Host, smtp.Port );
smtp.recepient = "jackie.oliver@benziga.com ";
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
so if my company email is jay.ronda@benziga.com (company domain is benziga.com)
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.benziga.com';
var Username:String ='jay.ronda@benziga.com';
var Password:String = 'xxxxxxx'; --my password
var frmLbl:String = 'SMTP Mailer <jay.ronda@benziga.com>'; --is this right ?
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
smtp.Port = 25; -- will this change for my company?
smtp.connect(smtp.Host, smtp.Port );
smtp.recepient = "jackie.oliver@benziga.com
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
smtp.Port = 25; -- will this change for my company?
It's standard SMTP port number but you have to confirm with your System Administrator what SMTP port are you using.
It's standard SMTP port number but you have to confirm with your System Administrator what SMTP port are you using.
ASKER
hi
In smtpsocket.as , i see this line
else if (code == "235") { //Authentication successful
this.writeUTFBytes ("MAIL FROM: <devaraj@wp.pl>\r\n");
do you know what should i substitute devaraj@wp.pl with ?
as i was suspecting , i am getting some port error
>>>
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://localhost:9081/technoweb/techflex/main.swf cannot load data from smtp.benziga.com:25.
In smtpsocket.as , i see this line
else if (code == "235") { //Authentication successful
this.writeUTFBytes ("MAIL FROM: <devaraj@wp.pl>\r\n");
do you know what should i substitute devaraj@wp.pl with ?
as i was suspecting , i am getting some port error
>>>
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://localhost:9081/technoweb/techflex/main.swf cannot load data from smtp.benziga.com:25.
I cannot share my code I gave you example what I used 1 year ago. May be you need to download latest latest SMTPMailer.
http://www.bytearray.org/wp-content/projects/smtpmailer/SMTPMailer%200.6.zip
http://www.bytearray.org/wp-content/projects/smtpmailer/SMTPMailer%200.6.zip
Or better to download grom Google http://code.google.com/p/smtpmailer/downloads/detail?name=SMTPMailer 0.9.zip
You can also try http://code.google.com/p/as3maillib/
ASKER
no prob.
I down loaded smtpmailer from http://www.bytearray.org/wp-content/projects/smtpmailer/SMTPMailer%200.6.zip
i see lot of .as files. smtpmailer.as , smtpevent.as , ect
so do you mean i need to replace smtpsocket.as with smtpmailer.as ?
thanks
I down loaded smtpmailer from http://www.bytearray.org/wp-content/projects/smtpmailer/SMTPMailer%200.6.zip
i see lot of .as files. smtpmailer.as , smtpevent.as , ect
so do you mean i need to replace smtpsocket.as with smtpmailer.as ?
thanks
No you can get latest project from Google
http://code.google.com/p/smtpmailer/downloads/detail?name=SMTPMailer 0.9.zip
or
http://code.google.com/p/as3maillib/
And find example or documentation on the internet
When I start working on SMTP client I used SmtpSocket.as what I attached in my first email its small and very basic, but I modified for my server and added additional API's what may exists already in Open Source project.
http://code.google.com/p/smtpmailer/downloads/detail?name=SMTPMailer 0.9.zip
or
http://code.google.com/p/as3maillib/
And find example or documentation on the internet
When I start working on SMTP client I used SmtpSocket.as what I attached in my first email its small and very basic, but I modified for my server and added additional API's what may exists already in Open Source project.
ASKER
ok , got it. thanks
I am gonna talk to my admin and find the right smtp port, most problly thats the issue.
thx.
I am gonna talk to my admin and find the right smtp port, most problly thats the issue.
thx.
No problem, check what protocol you are using, if IMAP it may be hard to find exisitng code.
ASKER
we are using SMTP only, but there is most probably a firewall which is blocking me.
thx for all your help.
thx for all your help.
You may need to use SSH or VPN in this case also verify if you are using SMTP\SSL connection.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thx suraj.
dgofman, have a question. spoke to my admin, he says keep the port empty , if doesnt work use the port 25 and use this server NJWEBX2408.msad.benziga.co m
I am trying without port first,so my new configuration is
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.NJWEBX2408.msad.benz iga.com';
var Username:String ='jay.ronda@benziga.com';
var Password:String = 'xxxxxxx'; --my password
var frmLbl:String = 'SMTP Mailer <jay.ronda@benziga.com>';
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
// smtp.Port = 25; //comment out
smtp.connect(smtp.Host, smtp.Port ); //do you know what should this be?connect function //doesnt take one parameter
smtp.recepient = "jackie.oliver@benziga.com ";
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
thanks
dgofman, have a question. spoke to my admin, he says keep the port empty , if doesnt work use the port 25 and use this server NJWEBX2408.msad.benziga.co
I am trying without port first,so my new configuration is
var smtp:SmtpSocket = new SmtpSocket();
var Host:String = 'smtp.NJWEBX2408.msad.benz
var Username:String ='jay.ronda@benziga.com';
var Password:String = 'xxxxxxx'; --my password
var frmLbl:String = 'SMTP Mailer <jay.ronda@benziga.com>';
smtp = new SmtpSocket()
smtp.Host = Host;
smtp.Username =Username;
smtp.Password = Password;
smtp.frmLbl =frmLbl;
// smtp.Port = 25; //comment out
smtp.connect(smtp.Host, smtp.Port ); //do you know what should this be?connect function //doesnt take one parameter
smtp.recepient = "jackie.oliver@benziga.com
smtp.QuickSubject = "My Test";
smtp.msgBody = "Hello World";
thanks
Sorry, is he junior admin?
You cannot connect to any host without port configuration.
Some are default for example when you are login to any web site you are using port 80
if you are login to bank application using HTTPS its port 443
SSH - 22
Telnet - 23
SMTP - 25
POP3 -110
So, I cannot understand his answer, ask somebody else.
You cannot connect to any host without port configuration.
Some are default for example when you are login to any web site you are using port 80
if you are login to bank application using HTTPS its port 443
SSH - 22
Telnet - 23
SMTP - 25
POP3 -110
So, I cannot understand his answer, ask somebody else.
ASKER
>>Sorry, is he junior admin?
heee, yes. i put the question through senior managment though and response received
you are trying to send email directly from flex to the SMTP server because of which browser is connecting directly to the SMTP server and is running into issues. Its better to send the email from the java, so you have client(flex) --> java (send email)
any thoughts?
thanks
heee, yes. i put the question through senior managment though and response received
you are trying to send email directly from flex to the SMTP server because of which browser is connecting directly to the SMTP server and is running into issues. Its better to send the email from the java, so you have client(flex) --> java (send email)
any thoughts?
thanks
Ok,
in this case you have two choices
1) Use some public SMTP server such as GMAIL
2) Using Suraj_Mathew files you can write java servlet what will except your request parameters from Flex and send via internal SMTP server.
Sorry,
David
in this case you have two choices
1) Use some public SMTP server such as GMAIL
2) Using Suraj_Mathew files you can write java servlet what will except your request parameters from Flex and send via internal SMTP server.
Sorry,
David
ASKER
yeah.
suraj, in your actual Sendmail.java class is there a way to figure out if the mail has been sucessfully sent ?
if(email sucessfull){
do something
}
else{
do something else
}
is that possible?
right now i see Transport.send(simpleMessa ge); which is probalby sending the email but i want to check the sucess.
thanks guys.
suraj, in your actual Sendmail.java class is there a way to figure out if the mail has been sucessfully sent ?
if(email sucessfull){
do something
}
else{
do something else
}
is that possible?
right now i see Transport.send(simpleMessa
thanks guys.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
works , thanks
SmtpSocket.as