Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added from name for mail api call #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions SendGrid/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Mail

private $to_list,
$from,
$from_name,
$cc_list,
$bcc_list,
$subject,
Expand Down Expand Up @@ -138,6 +139,28 @@ public function setFrom($email)
return $this;
}

/**
* setFromName
* set the from name
* @param String $name - a name
* @return the SendGrid\Mail object.
*/
public function setFromName($name)
{
$this->from_name = $name;
return $this;
}

/**
* getFromName
* get the from name
* @return the from name
*/
public function getFromName()
{
return $this->from_name;
}

/**
* getCc
* get the Carbon Copy list of recipients
Expand Down
1 change: 1 addition & 0 deletions SendGrid/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function _prepMessageData(Mail $mail)
'html' => $mail->getHtml(),
'text' => $mail->getText(),
'from' => $mail->getFrom(),
'fromname' => $mail->getFromName(),
'to' => $mail->getFrom(),
'x-smtpapi' => $mail->getHeadersJson()
);
Expand Down
9 changes: 9 additions & 0 deletions Test/SendGrid/MailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ public function testFromAccessors()
$this->assertEquals("foo@bar.com", $message->getFrom());
}

public function testFromNameAccessors()
{
$message = new SendGrid\Mail();

$message->setFromName("foo");

$this->assertEquals("foo", $message->getFromName());
}

public function testCcAccessors()
{
$message = new SendGrid\Mail();
Expand Down
2 changes: 2 additions & 0 deletions Test/SendGrid/WebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public function testMockFunctions()

$message->
setFrom('bar@foo.com')->
setFromName('foo')->
setSubject('foobar subject')->
setText('foobar text')->
addTo('foo@bar.com')->
Expand All @@ -34,6 +35,7 @@ public function testMockFunctions()
'html' => null,
'text' => 'foobar text',
'from' => 'bar@foo.com',
'fromname' => 'foo',
'to' => 'bar@foo.com',
'x-smtpapi' => '{"to":["foo@bar.com"]}',
'files[mynewattachment.jpg]' => '@mynewattachment.jpg'
Expand Down