Sharry India
Sharry India

Reputation: 351

Google App Engine using PHP set sender name while sending mails

Please help me to set sender name with sender email id in Google App Engine to send mails using PHP. So that receiver can also be able to see sender name with sender email ID. The code i tried is:

$sender=$_POST['from_id']; // i used '[email protected]' Note : this email id is authenticated to send mails
$to=$_POST['to_id'];   // i used '[email protected]'
$subject_of_mail=$_POST['subject_of_mail']; //test subject
$message_body=$_POST['message_body'];    //test body

$mail_options = [
            "sender" => $sender,
        "to" => $to,
        "subject" => $subject_of_mail,
    "htmlBody" => $message_body         
        ];

$message = new Message($mail_options);   

$message->send();

So , how can i add sender name in sender option with sender email ID. I am using PHP with Google App Engine & mails are send successfully by using the above code but i am not able to add sender name with sender email id. Please help me out of this problem.

Upvotes: 0

Views: 748

Answers (1)

koma
koma

Reputation: 6566

You cannot set the sender to any value you like. The sender address must be one of the following types:

  • The address of a registered administrator for the application. You can add administrators to an application using the Administration Console.
  • The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API. The user's account must be a Gmail account, or be on a domain managed by Google Apps.
  • Any valid email receiving address for the app (such as [email protected]).
  • Any valid email receiving address of a domain account, such as [email protected]. Domain accounts are accounts outside of the Google domain with email addresses that do not end in @gmail.com or @APP-ID.appspotmail.com.

see https://developers.google.com/appengine/docs/python/mail/sendingmail

Upvotes: 5

Related Questions