创建了一个简单的 Apache Commons Email 对象并编译它。进口:import org.apache.commons.mail._
并且javax.mail.internet.MimeMessage
还做了以下事情:
def sendVerification(user: User) = {
val email = new SimpleEmail()
email.setHostName("smtp.sendgrid.net")
email.setSmtpPort(465)
email.setAuthenticator(new DefaultAuthenticator("user", "pass"))
email.setSSLOnConnect(true)
email.setFrom("Community Admin <admin@domain.com>")
email.setSubject("TestMail")
email.setMsg("""Welcome %s!
Thanks for signing up. This email is to confirm your email address.
Cheers,
Admin Team
""" format user.firstName)
email.addTo(user.email)
email.send()
}
错误如下:
[error] C:\Users\path\to\AccountService\models\User.scala:43: object mail is not a member of package javax
[error] import javax.mail.internet.MimeMessage
[error] ^
[error] error while loading Email, Missing dependency 'class javax.mail.internet.MimeMessage', required by C:\Users\path\lib\commons-email-1.2.jar(org/apache/commons/mail/Email.class)
[error] C:\Users\path\com\threetierlogic\AccountService\models\User.scala:256: value setHostName is not a member of org.apache.commons.mail.SimpleEmail
[error] email.setHostName("smtp.sendgrid.net")
但是,当我去编译时,它会在调用的每个方法上引发错误val email
。这是与可变性有关的问题吗?或者版本有什么变化1.3
?