我正在开发一个电子邮件警报系统的应用程序,我已经放在一起。我使用cURL通过现有的SMTP服务器发送电子邮件,如下所示:
curl smtp://x.x.x.x --mail-from sender@example.com --mail-rcpt recipient@example.com --upload-file curlmail.txt
Curlmail.txt有以下数据:
From: sender@example.com
To: recipient.example.com
Subject: This is a test email
Test
我的问题是,电子邮件的标题似乎是发送到身体。即以下结果:我太新了,不适合嵌入图片
我希望在任何其他方法上使用curl,因为它似乎对我的用例是最好的--我在两个不同的服务器上实现了这个功能,在这些服务器上,MailX或sendMail可能无法按预期工作--或者工作方式不同。无论如何,任何帮助或建议都是非常感谢的--谢谢!
发布于 2022-09-09 12:36:31
您忘记了一些参数,例如端口、用户和<>上的curlmail.txt电子邮件地址。试试这个:
curl --ssl-reqd smtp://x.x.x.x:587 --mail-from sender@example.com --mail-rcpt recipient@example.com --user 'sender@example.com:sender_password' --upload-file curlmail.txt
只有当您需要使用SSL连接时,才需要参数--ssl-reqd
。
587是端口号。请为您的服务器使用正确的端口号。
添加发送方--user
和他的密码。请注意,用户可以是简单的名称或username@domain.com
然后,在您的curlmail.txt文件上,您应该使用这个头
From: "sender_name" <sender@example.com>
To: "recipient_name" <recipient.example.com>
Subject: This is a test email
Test
https://stackoverflow.com/questions/71442347
复制相似问题