int U_EXPORT main (int argc, char* argv[]) { U_ULIB_INIT(argv); U_TRACE(5,"main(%d)",argc) USmtpClient smtp; UString tmp(argv[1], strlen(argv[1])); if (smtp._connectServer(tmp)) { UString rcpt(argv[2], strlen(argv[2])); # ifdef USE_LIBSSL bool secure = (argc == 4); # else bool secure = false; # endif smtp.setSenderAddress(U_STRING_FROM_CONSTANT("< *****@*****.** >")); smtp.setRecipientAddress(rcpt); cout << (smtp.sendMessage(secure) ? "mail send" : "mail NOT send") << '\n'; // exit(0); } }
bool TSmtpMailer::cmdRcpt(const QList<QByteArray> &to) { if (to.isEmpty()) return false; for (QListIterator<QByteArray> i(to); i.hasNext(); ) { QByteArray rcpt("RCPT TO:<" + i.next() + '>'); if (cmd(rcpt) != 250) { return false; } } return true; }
bool TSmtpMailer::cmdRcpt(const QList<QByteArray> &to) { if (to.isEmpty()) return false; for (auto &tostr : to) { QByteArray rcpt("RCPT TO:<" + tostr + '>'); if (cmd(rcpt) != 250) { return false; } } return true; }
int smtp_client::mail_transaction(const string_ref& mailfrom, const string_ref& rcptto, const string_ref& bdy, posix_error_callback& ec) { /* returns 2xx on success */ int r = 0; if (!is_2xx(r = mail(mailfrom, ec))) { return r; } if (!is_2xx(r = rcpt(rcptto, ec))) { return r; } if (!is_3xx(r = data(ec))) { return r; /* asserted that r != 2xx */ } return body(bdy, ec); }
/** * Sets all the recipients with the RCPT command * to the smtp server. Multiple calls to this function * are expected if you have multiple To, CC and BCC * recipients. * * Params * sd - Socket descriptor * to - An e-mail address to send the message to * * Return * - ERROR * - SUCCESS */ int smtpSetRcpt(dsocket *sd, const char *to) { return rcpt(sd, to); }