在这篇文章中,我们将为您详细介绍我应该使用哪个spring库发送带有多线程的电子邮件的内容,并且讨论关于我应该使用哪个spring库发送带有多线程的电子邮件的相关问题。此外,我们还会涉及一些关于Cod
在这篇文章中,我们将为您详细介绍我应该使用哪个spring库发送带有多线程的电子邮件的内容,并且讨论关于我应该使用哪个spring库发送带有多线程的电子邮件的相关问题。此外,我们还会涉及一些关于Codeigniter发送带有附件的电子邮件、delphi – 如何发送带有日历请求的电子邮件(内容类型:文本/日历)、GoLang:无法发送带附件的电子邮件、PHP - 通过邮件从表单发送带有附件的电子邮件()的知识,以帮助您更全面地了解这个主题。
本文目录一览:- 我应该使用哪个spring库发送带有多线程的电子邮件(我应该使用哪个spring库发送带有多线程的电子邮件)
- Codeigniter发送带有附件的电子邮件
- delphi – 如何发送带有日历请求的电子邮件(内容类型:文本/日历)
- GoLang:无法发送带附件的电子邮件
- PHP - 通过邮件从表单发送带有附件的电子邮件()
我应该使用哪个spring库发送带有多线程的电子邮件(我应该使用哪个spring库发送带有多线程的电子邮件)
我的电子邮件太多了。我应该编写调度程序以便向他们发送消息。消息是不同的。我使用的是Spring Framework4.x。
我可以编写简单的类,它连接到SMTP服务器。但是在这种情况下,我也应该编写线程库以便并行发送电子邮件。
spring是否已经编写了库,这使我可以更灵活地完成此任务?我不想使用线程。如果spring已经具有此功能,那就太好了。
为此,我需要Spring集成吗?
最好的祝福,
答案1
小编典典是的,您绝对可以使用Spring Integration来做到这一点,因为Spring CoreExecutorChannel
可以提供带有的实现TaskExecutor
:
<channel id="sendEmailChannel"> <dispatcher task-executor="threadPoolTaskExecutor"/></channel><int-mail:outbound-channel-adapter channel="sendEmailChannel" mail-sender="mailSender"/>
但是无论如何,您应该记住所有Spring Integration组件都基于Java,并且ExecutorService
在后台使用。
从另一方面讲,如果您只需要Spring Integration的邮件发送内容,那将是一项开销,并且可以简单地使用Core Spring
Framework的遗留物(例如JavaMailSender
Bean)以及满足您需求@Async
的sendMail
方法parallel
。
更新
你能告诉我在这种情况下我是否需要JMS?
我在这里看不到任何与JMS相关的内容。您integration
的解决方案中没有(或至少不显示)任何实际点。我什至可以说,对于电子邮件发送来说,Spring
Integration也是如此。但是,使用Spring Boot,您的SI配置将足够短。从另一方面讲,如果您将更好地研究Spring
Integration,最终将获得更多收益,依靠您的系统的内部和外部组件,通过JMS,AMQP,Kafka等与其他系统配合使用。
坦白说:很多年前,我对Spring Integration的初次认识是由于需要从FTP获取文件并具有自动拾取新文件的能力。我仅在Spring
Integration中找到了解决方案1.0.0.M1
。在为<int-ftp:inbound-channel-adapter>
我完成了短暂的XML配置之后,我开始喜欢Spring Integration,从那时起,它就成为我生活的一部分。:-)
因此,您可以在简单的应用程序中继续进行Spring Integration,或者JavaMailSender
直接使用更正式的解决方案。
Codeigniter发送带有附件的电子邮件
我正在尝试在带有附件的codeigniter上发送电子邮件。
我总是成功收到电子邮件。但是,我从未收到带有附件的文件。以下是代码,非常感谢所有评论。
$ci = get_instance();
$ci->load->library('email');
$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "test@gmail.com";
$config['smtp_pass'] = "test";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n";
$ci->email->initialize($config);
$ci->email->from('test@test.com','Test Email');
$list = array('test2@gmail.com');
$ci->email->to($list);
$this->email->reply_to('my-email@gmail.com','Explendid Videos');
$ci->email->subject('This is an email test');
$ci->email->message('It is working. Great!');
$ci->email->attach( '/test/myfile.pdf');
$ci->email->send();
delphi – 如何发送带有日历请求的电子邮件(内容类型:文本/日历)
解决方法
program SendMailWithCalendarRequest; {$APPTYPE CONSOLE} uses IdSMTP,Classes,DateUtils,IdMessage,SysUtils; procedure SendCalendarRequest; var SMTP : TIdSMTP; MailMessage : TIdMessage; begin SMTP:= TIdSMTP.Create(nil); MailMessage := TIdMessage.Create(nil); try SMTP.Host := 'smtp.mailserver.com'; SMTP.Port := 25; SMTP.Username := 'the account'; SMTP.Password := 'the password'; SMTP.AuthType := satDefault; MailMessage.From.Address := 'mail@server.com'; MailMessage.Recipients.EMailAddresses := 'the Recipient'; MailMessage.Subject := 'Send calendar'; MailMessage.Body.Add('BEGIN:VCALENDAR'); MailMessage.Body.Add('VERSION:1.0'); MailMessage.Body.Add('BEGIN:VEVENT'); MailMessage.Body.Add('ORGANIZER:MAILTO:'+SenderMail); MailMessage.Body.Add('DTStart:'+FormatDateTime('YYYY-DD-DD',Now)); MailMessage.Body.Add('DTEnd:'+FormatDateTime('YYYY-DD-DD',Tomorrow)); MailMessage.Body.Add('Location;ENCODING=QUOTED-PRINTABLE: My home'); MailMessage.Body.Add('UID:'+FormatDateTime('YYYY-DD-DD',Now)+FormatDateTime('YYYY-DD-DD',Tomorrow)); MailMessage.Body.Add('SUMMARY:Appointment Reminder'); MailMessage.Body.Add('DESCRIPTION:Test message'); MailMessage.Body.Add('PRIORITY:5'); MailMessage.Body.Add('END:VEVENT'); MailMessage.Body.Add('END:VCALENDAR'); MailMessage.ContentType := 'text/calendar'; SMTP.Connect; try try SMTP.Send(MailMessage) ; Writeln('OK') except on E:Exception do Writeln(0,'ERROR: ' + E.Message) ; end; finally SMTP.disconnect; end; finally SMTP.Free; MailMessage.Free; end; end; begin try SendCalendarRequest; readln; except on E: Exception do Writeln(E.ClassName,': ',E.Message); end; end.
GoLang:无法发送带附件的电子邮件
php小编草莓今天给大家分享一篇关于GoLang的问题:无法发送带附件的电子邮件。在日常开发中,发送带附件的电子邮件是一个常见需求,但有时候我们会遇到一些问题。本文将介绍如何解决这个问题,帮助大家顺利发送带附件的电子邮件。我们将一步步解析问题的原因,并提供相应的解决方案,希望能帮到大家。
问题内容
我正在尝试使用以下代码发送带有附件的电子邮件:
package mail import ( "bytes" logging "project/logging" "fmt" "log" "mime/multipart" "net/textproto" "gopkg.in/mail.v2" ) func SendWithAttachment(from string, to []string, subject, bodyHTML string, attachmentName string, attachmentData []byte) error { logoURL := "/path/to/cs.jpg" m := mail.NewMessage() m.SetHeader("From", from) m.SetHeader("To", to...) m.SetHeader("Subject", subject) m.Embed(logoURL) // Create a multipart message body := &bytes.Buffer{} writer := multipart.NewWriter(body) // Add HTML part htmlPart := make(textproto.MIMEHeader) htmlPart.Set("Content-Type", "text/html") htmlPart.Set("Content-Transfer-Encoding", "quoted-printable") htmlPartWriter, err := writer.CreatePart(htmlPart) if err != nil { logging.NewDefaultLogger().Errorf("Error creating html part: %s", err) return err } htmlPartWriter.Write([]byte(bodyHTML)) // Add Attachment part attachmentPart := make(textproto.MIMEHeader) attachmentPart.Set("Content-Type", "application/octet-stream") attachmentPart.Set("Content-Transfer-Encoding", "base64") attachmentPart.Set("Content-Disposition", `attachment; filename="`+attachmentName+`"`) attachmentPartWriter, err := writer.CreatePart(attachmentPart) if err != nil { logging.NewDefaultLogger().Errorf("Error creating attachment part: %s", err) return err } attachmentPartWriter.Write(attachmentData) writer.Close() m.SetBody("multipart/mixed", body.String()) fmt.Printf("Sending mail.....") err = gs.dialer.DialAndSend(m) if err != nil { logging.NewDefaultLogger().Errorf("Error sending email..: %s", err) return err } return nil }
正文内容和附件内容均作为附件出现在名为“noname”的文件中。
附件文件内容如下:
立即学习“go语言免费学习笔记(深入)”;
--d885a04b467ae7d6100eb844c09574a6bdaef0a9796dc6fdde03a90613c9 内容传输编码:引用可打印 内容类型:text/html
... --d885a04b467ae7d6100eb844c09574a6bdaef0a9796dc6fdde03a90613c9 内容处置:附件;文件名=“resource_details.csv” 内容传输编码:base64 内容类型:应用程序/八位字节流附件内容..
--d885a04b467ae7d6100eb844c09574a6bdaef0a9796dc6fdde03a90613c9--
解决方法
我能够让它工作:
m := mail.NewMessage() m.SetHeader("From", emailDetails.From) m.SetHeader("To", emailDetails.To...) m.SetHeader("Subject", emailDetails.Subject) if emailDetails.BodyHTML != "" { m.SetBody("text/html", emailDetails.BodyHTML) } else { m.SetBody("text/plain", emailDetails.BodyPlain) } if emailDetails.AttachmentName != "" && len(emailDetails.AttachmentData) > 0 { m.Attach(emailDetails.AttachmentName, mail.SetCopyFunc(func(writer io.Writer) error { _, err := writer.Write(emailDetails.AttachmentData) return err })) }
以上就是GoLang:无法发送带附件的电子邮件的详细内容,更多请关注php中文网其它相关文章!
PHP - 通过邮件从表单发送带有附件的电子邮件()
如何解决PHP - 通过邮件从表单发送带有附件的电子邮件()?
我只想询问有关 PHP 电子邮件的问题。 我有一个通过 mail() 发送邮件的代码,但我不知道如何添加附件。 就像...您从我的网站填写并发送表格,然后发送到您的电子邮件中的是您填写的表格和新附件 - docx 文件(或 pdf) 你能帮我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
我们今天的关于我应该使用哪个spring库发送带有多线程的电子邮件和我应该使用哪个spring库发送带有多线程的电子邮件的分享就到这里,谢谢您的阅读,如果想了解更多关于Codeigniter发送带有附件的电子邮件、delphi – 如何发送带有日历请求的电子邮件(内容类型:文本/日历)、GoLang:无法发送带附件的电子邮件、PHP - 通过邮件从表单发送带有附件的电子邮件()的相关信息,可以在本站进行搜索。
本文标签: