kiwistag
asked on
Defaulting a GMail from Alias instead of a username with PEAR mail & PHP
As part of a site I've set the from field as an e-mail alias/nickname attached to a gmail apps account (gmail on a domain name address).
I've got the example here working on my site but it exposes the main account rather than the alias.
http://stackoverflow.com/q uestions/7 12392/send -email-usi ng-gmail-s mtp-server -from-php- page
I.E
$from = "bookings@domain.com"
$username = "employee@domain.com"
For some reason it doesn't default the e-mail from field as the $from variable to an e-mail sent to someone, it sends the $username instead...
Any ideas on how to fix this or is it something stuck with gmail / Google Apps?
I've got the example here working on my site but it exposes the main account rather than the alias.
http://stackoverflow.com/q
I.E
$from = "bookings@domain.com"
$username = "employee@domain.com"
For some reason it doesn't default the e-mail from field as the $from variable to an e-mail sent to someone, it sends the $username instead...
Any ideas on how to fix this or is it something stuck with gmail / Google Apps?
Please show us a short demonstration script that is having this issue. Blot out the password, but leave everything else exactly as you have it. Thanks, ~Ray
ASKER
Note that fwf.net & fwf.org are modified and that both domains are registered under the same google apps/gmail domain account. (i.e. e-mailing username@fwf.net goes to username@fwf.org) and that the nicknames/aliases are in place. fwf.org is the default domain.
<?
$subj="E-Mail Subject here";
$info="Thank you for submitting your REQUEST for the 2012 ....
Please click on the link below (or copy it to your browser) to continue to the next step.
***URL***
Until you do this - your full request WILL NOT be complete.
Please also ensure you read the document at the web address below. Note that in this case the postage application does not count.
***URL2***
Kind regards,
fwf.";
require_once "/usr/share/pear/Mail.php";
$from = "alias@fwf.net";
$to = $destemail;
$subject = $subj;
$body = $info;
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "username@fwf.org";
$password = "*password*";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
ASKER
Weirdly enough while playing with the code making only VERY minor tweaks it worked - I've redone some of it to support MAPI.
However... After finishing the MAPI code it reverted again! @#*%&#@&
However... After finishing the MAPI code it reverted again! @#*%&#@&
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Not the best solution but worth considering.