Skip to content

Problem in sending mail  #1799

Closed
Closed
@aishwaryacedcoss

Description

@aishwaryacedcoss

This is my email function but giving error :-
Invalid sender data
#0 /home/cedcommerce/public_html/demo/magento2/extensions/lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php(160): Magento\Email\Model\Template\SenderResolver->resolve('aishwarya@cedco...')
#1 /home/cedcommerce/public_html/demo/magento2/extensions/app/code/Ced/ReferAFriend/Model/Invitations.php(71): Magento\Framework\Mail\Template\TransportBuilder->setFrom('aishwarya@cedco...', 'Aishwarya')

FUNCTION :-
public function sendEmail($invitation)
{

    $baseUrl=$this->getBaseUrl();
    $Email_id=$invitation['email'];
    $subject=$invitation['subject'];
    $message=$invitation['message'];

    $store_id="1";


    $customer=$this->customerSession->getCustomer();
    $customer_id=$this->customerSession->getCustomerId();
    $customer_email=$customer->getEmail();
    $customer_name=$customer->getName();

    $baseUrl=$this->getBaseUrl()."customer/account/create/id/".$customer_id;
    $templateParams=['customer' => $Email_id, 'store' => $store_id,'subject' =>$subject,'message' => $message,'Website_link'=>$baseUrl];
     try{
    $transport = $this->_transportBuilder->setTemplateIdentifier(
        $this->_scopeConfig->getValue(self::XML_PATH_FORGOT_EMAIL_TEMPLATES, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store_id)
    )->setTemplateOptions(
        ['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $store_id]
    )/*->setTemplateVars(
        $templateParams
)*/ ->setFrom(
        'aishwarya@cedcoss.com',
         'Aishwarya'


) ->addTo(
        $Email_id,
        'Friend'
)->getTransport();
}
catch(Exception $e){
    echo $e->getMessage();
}
 $transport->sendMessage(); 
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions