private void nova_senha(HttpServletRequest request, HttpServletResponse response) throws XolerDAOException, IOException { String email = request.getParameter("email"); SendGrid sendgrid = new SendGrid("*****@*****.**", "3teptep3!"); SendGrid.Email sendgrid_email = new Email(); sendgrid_email.addTo(email); sendgrid_email.setFrom("*****@*****.**"); sendgrid_email.setSubject("Nova Senha"); DAOUsuario user = new DAOUsuario(true); int hash = email.hashCode(); String novasenha = Integer.toString(Math.abs(hash)); System.out.println("novasenha"); System.out.println(novasenha); user.nova_senha(email, novasenha); sendgrid_email.setText("Sua nova senha no Drogaria.me é: " + novasenha); try { SendGrid.Response response_sendgrid = sendgrid.send(sendgrid_email); System.out.println(response_sendgrid.getMessage()); } catch (SendGridException e) { System.err.println(e); } response.sendRedirect("index.jsp"); }
@Bean(name = "forgotPasswordEmail") public SendGrid.Email getForgotPasswordEmail() { SendGrid.Email email = new Email(); email.setFrom("*****@*****.**"); email.setSubject("[Forgot Password]"); email.setText("\n\n\n DO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\n"); return email; }
@Bean(name = "registrationEmail") public SendGrid.Email getRegistrationEmail() { SendGrid.Email email = new Email(); email.setFrom("*****@*****.**"); email.setSubject("[Registration]"); email.setText("\n\n\n DO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\n"); return email; }
@Bean(name = "reminderEmail") public SendGrid.Email getEmail() { SendGrid.Email email = new Email(); email.setFrom("*****@*****.**"); email.setSubject("[Reminder]"); email.setText( "\n\n\n DO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\nDO NOT REPLY THE MAIL\nANY QUESTION, PLEASE CONTACT "); return email; }
@Override protected Void doInBackground(Void... params) { try { // SendGrid sendgrid = new SendGrid(SENDGRID_USERNAME, SENDGRID_PASSWORD); SendGrid sendgrid = new SendGrid(SENDGRID_APIKEY); SendGrid.Email email = new SendGrid.Email(); // Get values from edit text to compose email // TODO: Validate edit texts email.addTo(toEditText.getText().toString()); email.setFrom(fromEditText.getText().toString()); email.setSubject(subjectEditText.getText().toString()); email.setText(msgEditText.getText().toString()); // Attach image if (selectedAudioURI != null) { email.addAttachment( attachmentName, getContentResolver().openInputStream(selectedAudioURI)); } // Send email, execute http request SendGrid.Response response = sendgrid.send(email); msgResponse = response.getMessage(); Log.d("SendAppExample", msgResponse); } catch (SendGridException e) { Log.e("SendAppExample", e.toString()); } catch (JSONException e) { Log.e("SendAppExample", e.toString()); } catch (IOException e) { Log.e("SendAppExample", e.toString()); } return null; }