mail.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package util
  2. import (
  3. "fmt"
  4. "log"
  5. "regexp"
  6. . "salesLeads/src/config"
  7. "time"
  8. "app.yhyue.com/moapp/jybase/mail"
  9. )
  10. func SendStructedDataByEmail(email string, auth []*mail.GmailAuth) bool {
  11. var uploadAddress = Sysconfig.Webdomain + Sysconfig.StructedUploadA
  12. var imagesAddress = Sysconfig.Webdomain + "/structuredata/mobile/image/emaillogo.png"
  13. var feedbackAddress = "mailto:bd@topnet.net.cn"
  14. if isEmail(email) {
  15. html := fmt.Sprintf(`<div style="width:100%%;display: flex;justify-content: center;">
  16. <div class="Email" id="Email" style="max-width:100%%;min-height: 540px;display: flex;flex-direction: column;align-items: center;">
  17. <div class="emailmain" style="border: 1px solid #ccc;max-width:100%%;height: 319px;border-top: 8px solid #2CB7CA;border-radius: 8px;background: #fff;margin: 0 auto; margin-top: 107px;padding: 0px 40px 20px;">
  18. <div class="emailmain_top" style="height: 88px;max-width:100%%;border-bottom: 1px solid #F7F7F7;display: flex;justify-content: center;align-items: center;">
  19. <img src="%s" alt="" style="width: 120px;height: 32px;">
  20. </div>
  21. <div class="emailmain_bottom" style="display: flex;flex-direction: column;align-items: center;">
  22. <p class="emailmain_text" style="margin-top: 32px;width: 100%%;min-height: 72px;font-size: 16px;line-height: 24px;color: #1D1D1D;">
  23. 尊敬的剑鱼标讯用户:<br> 您好,感谢您使用剑鱼标讯的结构化招标数据产品,免费样例已发送到您的邮箱,请查收!如有问题,可拨打<span style="color: #0987FF;cursor: pointer;">400-108-6670</span>,客服人员将诚挚为您服务。
  24. </p>
  25. <div class="download" style="margin-top: 32px; max-width:100%%; height: 30px;display: flex;justify-content: center;align-items: center;">
  26. <a href="%s" class="download_btn" style="width: 116px;height: 30px;display: flex;text-decoration: none;justify-content: center;align-items: center;font-size: 14px;line-height: 24px;color: #fff;background: #2CB7CA;border-radius: 4px;">下载免费样例 </a>
  27. </div>
  28. </div>
  29. </div>
  30. <p class="havapro" style="font-size: 14px;height: 24px;color: #686868;margin-top: 32px;">
  31. 如有问题请<a href="%s" class="click_here" id="click_here" style="color: #0987FF;cursor: pointer;">点击此处</a>,进行意见反馈
  32. </p>
  33. </div></div>`, imagesAddress, uploadAddress, feedbackAddress)
  34. for k, v := range auth {
  35. if mail.GSendMail("剑鱼标讯", email, "", "", "【剑鱼标讯】结构化招标数据", html, "", "", v) {
  36. log.Println(email, fmt.Sprintf("使用%s发送邮件成功", v.User))
  37. return true
  38. }
  39. if k < len(auth)-1 {
  40. log.Println(email, fmt.Sprintf("使用%s发送邮件失败!3s后使用其他邮箱尝试", v.User))
  41. } else {
  42. log.Println(email, fmt.Sprintf("使用%s发送邮件失败!", v.User))
  43. }
  44. time.Sleep(time.Second * 3)
  45. }
  46. } else {
  47. log.Println(fmt.Sprintf("%s 邮件格式有误", email))
  48. }
  49. return false
  50. }
  51. func isEmail(value string) bool {
  52. var emailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
  53. return emailPattern.MatchString(value)
  54. }