Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set from mail address other than smtp authentication mail in java mail

I am specifying "FROM" address usinf setFrom() method, But i still receive mails having "FROM" address of SMTP authentication mail id. and want to set the "FROM" address dynamically. which keeps changing. What is the RFC282 standard to achieve this.

like image 563
n92 Avatar asked Feb 12 '13 11:02

n92


People also ask

Can I use SMTP without authentication?

You can't use gmail smtp-server without authentication. It's a google policy. You need to enter your account password.

Which is the default port used for JavaMail?

Javamail will always use the port of the original test email. Example: User tries to send an email on port 25 and JavaMail says it can not connect on port 25 (for example, the SMTP host uses another port). User clicks port 587, and tries to send a new email.


2 Answers

The solution from google is this

Gmail lets you send messages with another of your email addresses listed as the sender instead of your Gmail address. This feature helps you manage multiple accounts from the Gmail interface; it works only if you already own the email account linked to the alternate address

  1. Select the Accounts and Import tab (or Accounts tab, if you're using Google Apps). Under Send mail as, click Add another email address. In the 'Email address' field, enter your name and alternate email address. Choose one of two options: Use Gmail's servers to send your mail (this is easier to set up) Use your other email provider's SMTP servers (we recommend this option for professional mail accounts or domains). Note for Google Apps users: Depending on your domain2 type, this feature may be disabled by default. Talk to your administrator if you have any questions. If you choose to use Gmail's servers:

  2. Click Next Step >> and then click Send Verification. Gmail will send a verification message to your other email address to confirm that you own it.

  3. Open your other account and either click the link in the message Gmail sent or enter the confirmation code in the Accounts section of your Gmail settings.

For more info, follow the below link

https://support.google.com/mail/bin/answer.py?hl=en&answer=22370.

The overhead involved is that any new from address needs a alias to be set in Gamil authentication mail account. Its not suits for enterprise salable app.

Other solution is You can install a mail server (hmailServer). This server allows you to set the custom from address

If any body knows other solutions, please suggest me.

like image 65
n92 Avatar answered Nov 12 '22 00:11

n92


It's up to your mail server. Often mail servers will prevent you from using any From address other than your actual login name. This helps prevent spam. Depending on your mail server, there may be ways to convince it that you should be allowed to use other From addresses.

like image 26
Bill Shannon Avatar answered Nov 11 '22 22:11

Bill Shannon