Forum Discussion

Ravikaanth's avatar
Ravikaanth
Contributor
9 months ago

Can't able to send a file through email

Hi team,

 

I am trying to send a file through an email, but I am getting an socket error. Please help me to resolve this issue. Thanks in advance.

 

Please find the below code for your reference,

 

if(BuiltIn.SendMail("receiver mail id","smtp.hostinger.com","Ravikaanth N S","sender mail id","Test Report","Please find the attached report","E:\\MBTEST\\MBAutomation\\new.txt"))
{
Log.Message("Mail was sent");
}
else
{
Log.Warning("Mail was not sent");
}

 

Please find the below error for your reference, 

 

JavaScript runtime error.
Socket Error # 10054
Connection reset by peer.

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    You can also try sending it to an email outside your organization just to test the connection. 

    • Ravikaanth's avatar
      Ravikaanth
      Contributor

      Marsha_R  Yes, I tried with my Gmail id, Please check the below code,

       

      if(BuiltIn.SendMail("ravikaanth2911@gmail.com","smtp.gmail.com","Ravikaanth","ravikaanth0606@gmail.com","Test Report","Please find the attached report","E:\\MBTEST\\MBAutomation\\new.txt"))

       

      Also I tried without attaching the file, It shows below error

       

      Unable to send email to the smtp.gmail.com server.

       

      Error message: "Must issue a STARTTLS command first. y12-20020a63fa0c000000b0051b36aee4f6sm2424658pgh.83 - gsmtp."
  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't think Gmail will allow you to send unauthenticated third party emails via their servers called open mail relay.

     

    If you are connected to your network organisation, you might be able to send a third party email using your current credentials.