I would like to use pub.client:smtp to send an email out to an external address (i.e. firstname.lastname@example.org), but the ‘status’ returned is always ‘Mail was sent successfully’ . Even if my “to” address is horribly wrong (i.e. somebody@), it will still return the message ‘Mail was sent successfully’. Hence I can never know when it failed.
Please advise on using another service to get the job done.
Are you setting correct smtp host/ip and pop3/IMAP user info etc…??
You’re right – I just noticed there’s a global value being assigned to the input mailhost (internalmail.domain.com). So other than to, subject, from &, body, what do I need to set for input mailhost, if I’m sending the email externally?
For sending mail, it doesn’t matter if it is internally or externally–the mailhost should point to an SMTP server. If your example of internalmail.domain.com identifies an SMTP server, then that’s okay.
And that won’t address the address format issue anyway. If you want to validate the address format before sending to the SMTP server, write a wrapper service for pub.client:smtp to do so.
Set the from to a valid from e-mail address and your SMTP server will send an e-mail to that address for any errors encountered.
So are we coming to a conclusion that there’s no way to validate beyond email-format rules? Meaning once we get past the checks for valid email format (email@example.com), there’s no way to see if firstname.lastname@example.org actually exists?
To a degree, it’s a limitation of SMTP. Typical e-mail clients don’t validate addresses either. The SMTP server you’re talking to doesn’t know whether or not email@example.com is a valid mailbox. It won’t know that until it tries to deliver the e-mail to the SMTP server at nowhere.com. And it normally won’t do that until after your SMTP session is long gone (SMTP is more or less a store and forward facility). Of course, someone please correct me if my description is off.
As I mentioned, if the target TO addresses are bad, the FROM address will likely get a response e-mail indicating the trouble. But that’s not guaranteed.