NS_IMETHODIMP nsSmtpService::SendMailMessage(nsIFile * aFilePath, const char * aRecipients, nsIMsgIdentity * aSenderIdentity, const char * aPassword, nsIUrlListener * aUrlListener, nsIMsgStatusFeedback *aStatusFeedback, nsIInterfaceRequestor* aNotificationCallbacks, PRBool aRequestDSN, nsIURI ** aURL, nsIRequest ** aRequest) { nsIURI * urlToRun = nsnull; nsresult rv = NS_OK; nsCOMPtr<nsISmtpServer> smtpServer; rv = GetSmtpServerByIdentity(aSenderIdentity, getter_AddRefs(smtpServer)); if (NS_SUCCEEDED(rv) && smtpServer) { if (aPassword && *aPassword) smtpServer->SetPassword(nsDependentCString(aPassword)); // this ref counts urlToRun rv = NS_MsgBuildSmtpUrl(aFilePath, smtpServer, aRecipients, aSenderIdentity, aUrlListener, aStatusFeedback, aNotificationCallbacks, &urlToRun, aRequestDSN); if (NS_SUCCEEDED(rv) && urlToRun) rv = NS_MsgLoadSmtpUrl(urlToRun, nsnull, aRequest); if (aURL) // does the caller want a handle on the url? *aURL = urlToRun; // transfer our ref count to the caller.... else NS_IF_RELEASE(urlToRun); } return rv; }
nsresult nsSmtpService::SendMailMessage(nsIFile * aFilePath, const char * aRecipients, nsIMsgIdentity * aSenderIdentity, const char * aPassword, nsIUrlListener * aUrlListener, nsIMsgStatusFeedback *aStatusFeedback, nsIInterfaceRequestor* aNotificationCallbacks, PRBool aRequestDSN, nsIURI ** aURL, nsIRequest ** aRequest) { nsIURI * urlToRun = nsnull; nsresult rv = NS_OK; nsCOMPtr<nsISmtpServer> smtpServer; rv = GetSmtpServerByIdentity(aSenderIdentity, getter_AddRefs(smtpServer)); if (NS_SUCCEEDED(rv) && smtpServer) { if (aPassword && *aPassword) smtpServer->SetPassword(aPassword); nsCString smtpHostName; nsCString smtpUserName; PRInt32 smtpPort; PRInt32 trySSL; smtpServer->GetHostname(getter_Copies(smtpHostName)); smtpServer->GetUsername(getter_Copies(smtpUserName)); smtpServer->GetPort(&smtpPort); smtpServer->GetTrySSL(&trySSL); if (smtpPort == 0) { if (trySSL == PREF_SECURE_ALWAYS_SMTPS) smtpPort = nsISmtpUrl::DEFAULT_SMTPS_PORT; else smtpPort = nsISmtpUrl::DEFAULT_SMTP_PORT; } if (!smtpHostName.IsEmpty() && !CHECK_SIMULATED_ERROR(SIMULATED_SEND_ERROR_10)) { rv = NS_MsgBuildSmtpUrl(aFilePath, smtpHostName, smtpPort, smtpUserName, aRecipients, aSenderIdentity, aUrlListener, aStatusFeedback, aNotificationCallbacks, &urlToRun, aRequestDSN); // this ref counts urlToRun if (NS_SUCCEEDED(rv) && urlToRun) { nsCOMPtr<nsISmtpUrl> smtpUrl = do_QueryInterface(urlToRun, &rv); if (NS_SUCCEEDED(rv)) smtpUrl->SetSmtpServer(smtpServer); rv = NS_MsgLoadSmtpUrl(urlToRun, nsnull, aRequest); } if (aURL) // does the caller want a handle on the url? *aURL = urlToRun; // transfer our ref count to the caller.... else NS_IF_RELEASE(urlToRun); } else rv = NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER; } return rv; }