Jahia Dev Forum > How can i sent email

0 (0 Good)
0 (0 Bad)

How can i sent email

by  obayok »  2012/10/10 08:19

Hi, all.

I need to sent email, i fill my form and for submit action i have own action

public class SentMail extends Action {

    private MailService mailService;

    public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource,
                                  JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver) throws Exception {
    ....
        if (mailService.isEnabled()) {
            mailService.sendMessage("fromolga@mail.com","toolga@mail.com", "this is message");
        }
        return new ActionResult(HttpServletResponse.SC_OK);
    }

    public void setMailService(MailService mailService) {
        this.mailService = mailService;
    }
}

 

but i recieve mail from address with i have in mail setting.

smtps://smtp.gmail.com?username=olga@gmail.com&password=1111

 

Can i use mailSevice for sent mail from user to any mail?

 

Thanks

  • How can i sent email
    2012/10/10 13:51

    obayok <p> Hi, all.</p> <p> I need to sent email, i fill my form and for submit action i have own action</p> <p> public class SentMail extends Action {<br /> <br /> &nbsp;&nbsp;&nbsp; private MailService mailService;<br /> <br /> &nbsp;&nbsp;&nbsp; public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource,<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JCRSessionWrapper session, Map&lt;String, List&lt;String&gt;&gt; parameters, URLResolver urlResolver) throws Exception {<br /> &nbsp;&nbsp;&nbsp; ....<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (mailService.isEnabled()) {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mailService.sendMessage(&quot;fromolga@mail.com&quot;,&quot;toolga@mail.com&quot;, &quot;this is message&quot;);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new ActionResult(HttpServletResponse.SC_OK);<br /> &nbsp;&nbsp;&nbsp; }<br /> <br /> &nbsp;&nbsp;&nbsp; public void setMailService(MailService mailService) {<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.mailService = mailService;<br /> &nbsp;&nbsp;&nbsp; }<br /> }</p> <p> &nbsp;</p> <p> but i recieve mail from address with i have in mail setting.</p> <p> smtps://smtp.gmail.com?username=olga@gmail.com&amp;password=1111</p> <p> &nbsp;</p> <p> Can i use mailSevice for sent mail from user to any mail?</p> <p> &nbsp;</p> <p> Thanks</p>

  • Number of messages  11
    Registration date Oct 10, 2012
    0 (0 Good)
    0 (0 Bad)

    Re: How can i sent email

    by  faissah »  2012/10/12 21:57

    Hi,

    Yes, you can use mailSevice in order to send email, this is what we use for our default modules. Have you well setted and tested your email settings? (there is a test settings button in the "Email Settings" panel).

    The "from" you setted there will be the sender of the email unless you provide one.

    When the code is executed, do you have anything in the logs ?

    Regards,

    Fabrice

    Fabrice  (faissah)

    Number of messages  264
    Registration date
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page