Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 788796d

Browse files
committed
GMAIL - Set display name for email sending
1 parent 367d4b7 commit 788796d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

modules/google/gmail/service/src/main/java/com/funixproductions/api/google/gmail/service/config/GoogleGmailConfig.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.funixproductions.api.google.gmail.service.config;
22

3-
import com.google.api.client.http.HttpRequestInitializer;
43
import com.google.api.client.http.javanet.NetHttpTransport;
54
import com.google.api.client.json.gson.GsonFactory;
65
import com.google.api.services.gmail.Gmail;
@@ -28,15 +27,19 @@ public class GoogleGmailConfig {
2827
*/
2928
private String appEmail = "noreply@funixproductions.com";
3029

30+
/**
31+
* App sender display name
32+
*/
33+
private String appEmailName = "FunixProductions";
34+
3135
@Bean
3236
public GoogleCredentials googleCredentials() throws Exception {
3337
return GoogleCredentials.getApplicationDefault().createScoped(GmailScopes.GMAIL_SEND).createDelegated(this.appEmail);
3438
}
3539

3640
@Bean
3741
public Gmail gmail(GoogleCredentials googleCredentials) {
38-
final HttpRequestInitializer requestInitializer = new HttpCredentialsAdapter(googleCredentials);
39-
return new Gmail.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer)
42+
return new Gmail.Builder(new NetHttpTransport(), new GsonFactory(), new HttpCredentialsAdapter(googleCredentials))
4043
.setApplicationName("FunixProductions Gmail Service")
4144
.build();
4245
}

modules/google/gmail/service/src/main/java/com/funixproductions/api/google/gmail/service/services/GoogleGmailService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public GoogleGmailService(Gmail gmailService,
4747
this.templateMail = StringUtils.readFromClasspath(TEMPLATE_FILE_NAME, this.getClass());
4848

4949
try {
50-
this.serverEmailAddress = new InternetAddress(gmailConfig.getAppEmail());
51-
} catch (MessagingException e) {
50+
this.serverEmailAddress = new InternetAddress(gmailConfig.getAppEmail(), gmailConfig.getAppEmailName());
51+
} catch (Exception e) {
5252
throw new ApiException("Can't set server email address", e);
5353
}
5454
}

0 commit comments

Comments
 (0)