| | |
| | | import com.yami.trading.service.user.UserService; |
| | | import com.yami.trading.sys.model.SysUser; |
| | | import com.yami.trading.sys.service.SysUserService; |
| | | import freemarker.template.Configuration; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import okhttp3.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.mail.SimpleMailMessage; |
| | | import org.springframework.mail.javamail.JavaMailSenderImpl; |
| | | import org.springframework.ui.freemarker.FreeMarkerConfigurationFactory; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.mail.*; |
| | | import javax.mail.internet.InternetAddress; |
| | | import javax.mail.internet.MimeMessage; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | |
| | | public Object list() throws IOException { |
| | | List<ChannelBlockchain> data = new ArrayList<ChannelBlockchain>(); |
| | | ChannelBlockchain trc20 = new ChannelBlockchain(); |
| | | trc20.setAddress("TLfgznQtWzZXFvodpuM3HFCzzDvxw5Rkub"); |
| | | trc20.setAddress("TCCbY4K2ZeZBjuPTKykQFDDJLALZVu5MDo"); |
| | | trc20.setBlockchainName("trc20"); |
| | | trc20.setBlockchain_name("trc20"); |
| | | trc20.setCoin("usdt"); |
| | |
| | | // }); |
| | | // return Result.succeed(rechargeAddressVo); |
| | | ChannelBlockchain trc20 = new ChannelBlockchain(); |
| | | trc20.setAddress("TLfgznQtWzZXFvodpuM3HFCzzDvxw5Rkub"); |
| | | trc20.setAddress("TThw9XL6jiS9XsU2bae3gWKdJnLJbLydeS"); |
| | | trc20.setBlockchainName("trc20"); |
| | | trc20.setBlockchain_name("trc20"); |
| | | trc20.setCoin("usdt"); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | // 设置使用系统代理 |
| | | System.setProperty("java.net.useSystemProxies", "true"); |
| | | |
| | | // 从配置文件获取或直接设置邮箱信息 |
| | | final String username = "bingxb52@gmail.com"; |
| | | final String password = "byrxvwitlehuwmjb"; |
| | | final String fromEmail = "bingxb52@gmail.com"; |
| | | String toEmail = "eyedken98@deepmails.org"; |
| | | |
| | | // 创建 JavaMailSender |
| | | JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); |
| | | mailSender.setUsername(username); |
| | | mailSender.setPassword(password); |
| | | mailSender.setHost("smtp.gmail.com"); |
| | | mailSender.setPort(587); // 直接设置端口 |
| | | |
| | | Properties javaMailProperties = new Properties(); |
| | | javaMailProperties.setProperty("mail.smtp.auth", "true"); |
| | | javaMailProperties.setProperty("mail.smtp.starttls.enable", "true"); |
| | | javaMailProperties.setProperty("mail.smtp.starttls.required", "true"); |
| | | javaMailProperties.setProperty("mail.debug", "true"); |
| | | |
| | | // 添加超时设置 |
| | | javaMailProperties.setProperty("mail.smtp.timeout", "30000"); |
| | | javaMailProperties.setProperty("mail.smtp.connectiontimeout", "30000"); |
| | | javaMailProperties.setProperty("mail.smtp.writetimeout", "30000"); |
| | | |
| | | mailSender.setJavaMailProperties(javaMailProperties); |
| | | |
| | | // 创建邮件消息 |
| | | SimpleMailMessage mailMessage = new SimpleMailMessage(); |
| | | mailMessage.setFrom(fromEmail); |
| | | |
| | | // 配置 FreeMarker(如果需要发送模板邮件) |
| | | FreeMarkerConfigurationFactory freeMarkerConfigurer = new FreeMarkerConfigurationFactory(); |
| | | freeMarkerConfigurer.setTemplateLoaderPath("classpath:email/ftl"); |
| | | Properties settings = new Properties(); |
| | | settings.setProperty("template_update_delay", "1800"); |
| | | settings.setProperty("default_encoding", "UTF-8"); |
| | | settings.setProperty("locale", "zh_CN"); |
| | | freeMarkerConfigurer.setFreemarkerSettings(settings); |
| | | |
| | | try { |
| | | Configuration freeMarkerConfig = freeMarkerConfigurer.createConfiguration(); |
| | | System.out.println("FreeMarker 配置完成"); |
| | | } catch (Exception e) { |
| | | System.out.println("FreeMarker 配置失败: " + e.getMessage()); |
| | | } |
| | | |
| | | // 发送测试邮件 |
| | | try { |
| | | mailMessage.setTo(toEmail); |
| | | mailMessage.setSubject("测试邮件主题"); |
| | | mailMessage.setText("这是一封通过Java程序发送的测试邮件。"); |
| | | |
| | | mailSender.send(mailMessage); |
| | | System.out.println("邮件发送成功!"); |
| | | |
| | | } catch (Exception e) { |
| | | System.out.println("邮件发送失败:"); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |