java - Javamail logging to service with FROM value -
i'm using javamail in mailing service. code:
public static void send( final string username, final string password, string recipientemail, string ccemail, string title, string message, string from, string host, string port ) throws addressexception, messagingexception { session session; properties props = system.getproperties(); props.setproperty( "mail.smtps.host", host ); props.setproperty( "mail.smtp.port", port ); session = session.getinstance( props, null ); // -- create new message -- final mimemessage msg = new mimemessage( session ); // -- set , fields -- msg.setfrom( new internetaddress( username ) ); msg.setrecipients( message.recipienttype.to, internetaddress.parse( recipientemail, false ) ); if ( ccemail.length() > 0 ) { msg.setrecipients( message.recipienttype.cc, internetaddress.parse( ccemail, false ) ); } msg.setsubject( title, "utf-8" ); msg.setfrom( new internetaddress( ) ); msg.settext( message, "utf-8" ); msg.setsentdate( new date() ); smtptransport t = (smtptransport) session.gettransport( "smtps" ); t.connect( host, username, password ); t.sendmessage( msg, msg.getallrecipients() ); t.close(); } i call method giving e.g - username: mailtest - from: super company <- domain - host: mail.host.com <- mail provider
and javamail trying log in service mailtest@mysupercompany.com , fails. when give e.g: test@mysupercompany.com works fine.
i've checked logs in console , says user mailtest@mysupercompany.com not exist. it's javamail try login mailtest@mysupercompany.com, should use username mailtest.
why using when it's same username?
it should using whatever pass in username. make sure it's expect; print out before connect call.
add session.setdebug(true). debug output show?
Comments
Post a Comment