Skip to content

Commit

Permalink
Extended Mail.from(email, [name]) method by adding name argument …
Browse files Browse the repository at this point in the history
…by Marek Mráz.
  • Loading branch information
petersirka committed Oct 28, 2024
1 parent bfbdd23 commit 83b1154
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- reduced DNS cache flush time to 3 minutes
- added `$.address` property with the absolute URL address
- added `$.ctrl(ctrl_instance)` method
- extended `Mail.from(email, [name])` method by adding `name` argument by [Marek Mráz](https://github.com/Mrazbb)
- added `CONF.mail_from_name {String}` option

========================
0.0.6
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function unlink(arr, callback) {
} else
msg.to(email);

msg.from(F.config.mail_from || F.config.smtp.from || F.config.smtp.user);
msg.from(F.config.mail_from || F.config.smtp.from || F.config.smtp.user, F.config.mail_from_name);
callback && msg.callback(callback);

if (reply)
Expand Down
5 changes: 3 additions & 2 deletions mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ Message.prototype.callback = function(fn) {
return this;
};

Message.prototype.sender = Message.prototype.from = function(email) {
Message.prototype.sender = Message.prototype.from = function(email, name) {
this.email_from = email;
this.email_from_name = name;
return this;
};

Expand Down Expand Up @@ -571,7 +572,7 @@ Mailer.$writemessage = function(obj, buffer) {
self.$priority && message.push('X-Priority: ' + self.$priority);
self.$confidential && message.push('Sensitivity: Company-Confidential');

message.push('From: <' + msg.email_from + '>');
message.push('From: ' + (msg.email_from_name ? (unicode_encode(msg.email_from_name) + ' <' + msg.email_from + '>') : msg.email_from));

if (msg.headers) {
for (let key in msg.headers)
Expand Down

0 comments on commit 83b1154

Please sign in to comment.