我需要刷新SMTP服务器吗?如果是,该怎么办?

| 一段时间以来,我一直在努力通过Haskell程序发送电子邮件表单,试图使用HaskellMime库或类似的库,但是失败了。 我最近安装了HaskellNet,并尝试使用Haskellnet.SMTP模块。 我尝试使用\'sendMail \'命令发送电子邮件,并收到\“用户错误(sendMail错误)\”。我想这是因为我使用的SMTP服务器需要身份验证。 我看了一下\'sendMail \'的源代码,并最终编写了这个简单的主代码:http://hpaste.org/47841 我检查了每个\'sendCommand \'命令,在AUTH命令之后,我从SMTP服务器获得了\“验证成功\”,并从其他命令中获得了250个代码,如\'sendMail \'源代码中所期望的那样。 问题是我的邮箱中没有任何邮件,所以我做错了什么?我唯一能想到的是,邮件在SMTP传出列表中排队的某个地方,我需要刷新SMTP服务器,但这不是\'sendMail \'代码的一部分,所以我想知道... 任何帮助将不胜感激,因为我从未想过发送电子邮件会如此困难:/ 附言我在手机上使用完全相同的设置来与此SMTP服务器发送电子邮件,相同的\“ smtp.sfr.fr \”,相同的ID(整个地址),相同的密码;它的工作原理是:我可以通过手机发送邮件。 先谢谢您的帮助。     
已邀请:
        尽管我无法评论您对HaskellNet的使用,但使用SMTPClient取得了巨大的成功,您可以使用
cabal install SMTPClient
从hack中获取。 我已经提供了该包的示例,以使您大致了解使用该库的方式:
import Network.SMTP.ClientSession
import Network.SMTP.Client
import Network.Socket
import System.Time
import System.IO
import Data.Bits
import Data.IORef

myDomain = \"example.com\"
smtpHost = \"hubert.blacksapphire.com\"    -- <-- Your SMTP server here

-- This will send the author an email.  I don\'t mind!
main = do
    now <- getClockTime
    nowCT <- toCalendarTime now
    let message = Message [
                From [NameAddr (Just \"Mr. Nobody\") \"nobody@example.com\"],
                To   [NameAddr (Just \"Stephen Blackheath\") \"unprintable.distances.stephen@blacksapphire.com\"],
                Subject \"I\'m using SMTPClient!\",
                Date nowCT
            ]
            (\"Dear Sir,\\n\"++
             \"It has come to my attention that this is an email.\\n\"++
             \"Yours sincerely,\\n\"++
             \"Mr. Nobody\\n\")
    addrs <- getAddrInfo Nothing (Just smtpHost) Nothing
    let SockAddrInet _ hostAddr = addrAddress (addrs !! 0)
        sockAddr = SockAddrInet (fromIntegral 25) hostAddr
    putStrLn $ \"connecting to \"++show sockAddr
    sentRef <- newIORef []
    sendSMTP\' (hPutStrLn stderr) (Just sentRef) myDomain
        sockAddr [message]
    statuses <- readIORef sentRef
    -- If no exception was caught, statuses is guaranteed to be
    -- the same length as the list of input messages, therefore head won\'t fail here.
    case head statuses of
        Nothing     -> putStrLn \"Message successfully sent\"
        Just status -> putStrLn $ \"Message send failed with status \"++show status
    

要回复问题请先登录注册